Skip to content

http: add timeout option to server.close() - #67851

Merged
nodejs-github-bot merged 4 commits into
nodejs:mainfrom
araujogui:http-server-close-timeout
Dec 3, 2026
Merged

nodejs-github-bot merged 4 commits into
nodejs:mainfrom
araujogui:http-server-close-timeout

Conversation

@araujogui

Copy link
Copy Markdown
Member

server.close() waits forever for active connections, so one slow or stuck request keeps the server from closing.

This adds a timeout option, in milliseconds, to close() on http.Server and https.Server. Connections still open when it elapses are destroyed with closeAllConnections().

HTTP/2 servers are not covered.

server.close() waits indefinitely for connections that are sending a
request or waiting for a response, so a single slow or stuck request
keeps the server from closing.

Add an optional `options` argument with a `timeout` in milliseconds to
`http.Server` and `https.Server`. Connections that are still open when
it elapses are destroyed with `closeAllConnections()`.

Assisted-by: Claude
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 28, 2026 16:23
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/http
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added http Issues and PRs related to the http subsystem. https Issues and PRs related to the https subsystem. needs-ci PRs that need a full CI run. labels Nov 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.45455% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.58%. Comparing base (d3f8545) to head (47dc92e).
⚠️ Report is 99 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/http/server.js 95.23% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67851      +/-   ##
==========================================
+ Coverage   90.53%   90.58%   +0.04%     
==========================================
  Files         805      802       -3     
  Lines      285842   286792     +950     
  Branches    55187    55407     +220     
==========================================
+ Hits       258793   259786     +993     
+ Misses      17167    17099      -68     
- Partials     9882     9907      +25     
Files with missing lines Coverage Δ
lib/https.js 97.25% <100.00%> (-0.01%) ⬇️
lib/internal/http/server.js 96.70% <95.23%> (+0.04%) ⬆️

... and 85 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread lib/internal/http/server.js Resolved
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
@araujogui araujogui added the semver-minor PRs that contain new features and should be released in the next minor version. label Nov 30, 2026

@Ethan-Arrowood Ethan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in favor of this. FYI it complements #66000 and will probably result in a conflict once that merges. Just something to be aware of.

One thing to consider is what happens when close is called twice with different timeouts?

close({ timeout: 200 });
close({ timeout: 1000 });

Should this close at 200ms or at the updated 1000ms? Or should there be a different behavior?

Lastly, the commit mentions "Claude"; per our guidelines, this should be anonymized: https://github.com/nodejs/node/blob/main/doc/contributing/ai-guidelines.md#naming-ai-tools-in-disclosures

Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
@araujogui

Copy link
Copy Markdown
Member Author

in favor of this. FYI it complements #66000 and will probably result in a conflict once that merges. Just something to be aware of.

One thing to consider is what happens when close is called twice with different timeouts?

close({ timeout: 200 });
close({ timeout: 1000 });

Should this close at 200ms or at the updated 1000ms? Or should there be a different behavior?

Lastly, the commit mentions "Claude"; per our guidelines, this should be anonymized: https://github.com/nodejs/node/blob/main/doc/contributing/ai-guidelines.md#naming-ai-tools-in-disclosures

I made the earliest timeout win, so your example closes at 200ms. Added a test and a line in the docs.

Ethan-Arrowood added a commit to Ethan-Arrowood/agentic that referenced this pull request Dec 2, 2026
In the slot run for nodejs/node#67851, the session couldn't write its
probe to the slot's .claude/tmp/, though its allow rule covers the
whole checkout. In dontAsk mode, Claude Code refuses writes under any
.claude/ directory. A headless run confirmed it: the same write to a
folder beside it worked.

slot acquire now creates .review-tmp/ in the slot and adds it to the
clone's info/exclude, which its worktrees share, so the folder never
makes a slot dirty. The run recipes and the session rules use it. The
copied-test recipe's require rewrite changes to ../test/ to match the
new depth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Ethan-Arrowood Ethan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!

@Ethan-Arrowood Ethan-Arrowood added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue-squash PRs the Commit Queue should land as one squashed commit. labels Dec 2, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Dec 2, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Ethan-Arrowood added a commit to Ethan-Arrowood/agentic that referenced this pull request Dec 2, 2026
In the slot run for nodejs/node#67851, the session couldn't write its
probe to the slot's .claude/tmp/, though its allow rule covers the
whole checkout. In dontAsk mode, Claude Code refuses writes under any
.claude/ directory. A headless run confirmed it: the same write to a
folder beside it worked.

slot acquire now creates .review-tmp/ in the slot and adds it to the
clone's info/exclude, which its worktrees share, so the folder never
makes a slot dirty. The run recipes and the session rules use it. The
copied-test recipe's require rewrite changes to ../test/ to match the
new depth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread doc/api/http.md
end. If `options.timeout` is set, connections that are still open when it
elapses are destroyed with [`server.closeAllConnections()`][], which interrupts
any request in progress. Sockets upgraded to a different protocol, such as
WebSocket or HTTP/2, are not destroyed. Calling [`server.listen()`][] again

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but this is interesting, I didn't realise that closeAllConnections doesn't close all connections!

If we're changing things, that might also be worth exploring. I find it hard to imagine a use case where you want to close the server, but not those other sockets. Would be a separate semver-major PR anyway and this can stay consistent in the meantime.

Ethan-Arrowood added a commit to Ethan-Arrowood/agentic that referenced this pull request Dec 3, 2026
In the slot run for nodejs/node#67851, the session couldn't write its
probe to the slot's .claude/tmp/, though its allow rule covers the
whole checkout. In dontAsk mode, Claude Code refuses writes under any
.claude/ directory. A headless run confirmed it: the same write to a
folder beside it worked.

slot acquire now creates .review-tmp/ in the slot and adds it to the
clone's info/exclude, which its worktrees share, so the folder never
makes a slot dirty. The run recipes and the session rules use it. The
copied-test recipe's require rewrite changes to ../test/ to match the
new depth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ethan-Arrowood added a commit to Ethan-Arrowood/agentic that referenced this pull request Dec 3, 2026
In the slot run for nodejs/node#67851, the session couldn't write its
probe to the slot's .claude/tmp/, though its allow rule covers the
whole checkout. In dontAsk mode, Claude Code refuses writes under any
.claude/ directory. A headless run confirmed it: the same write to a
folder beside it worked.

slot acquire now creates .review-tmp/ in the slot and adds it to the
clone's info/exclude, which its worktrees share, so the folder never
makes a slot dirty. The run recipes and the session rules use it. The
copied-test recipe's require rewrite changes to ../test/ to match the
new depth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@araujogui araujogui added the commit-queue PRs queued for automated landing through the Commit Queue. label Dec 3, 2026
Ethan-Arrowood added a commit to Ethan-Arrowood/agentic that referenced this pull request Dec 3, 2026
…46)

* nodejs-review-bank: add bank.ts sweep and retire nodejs-review-queue

The cleanup sweep was the last thing only the queue skill had. bank.ts
sweep lists open networking PRs one label at a time, takes the oldest
batch not swept yet, and splits those whose authors went quiet for 6
months into stalled targets (external authors) and collaborator-parked
PRs. It measures the author's own last commit or comment, never
updatedAt. sweep mark records what the user did in <bank>/sweep.json,
so a PR stays out until its author pushes and then comes back as
REVIVED. The judgment steps move into SKILL.md's Cleanup sweep.

With that, nodejs-review-queue goes. The bank's description takes over
its triggers. README, agents/claude/README.md, and nodejs-contribute
point at the bank instead. The installer's prune_broken removes the
dangling ~/.claude/skills/nodejs-review-queue link on the next sync.

Closes #38.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* nodejs-review-bank: don't hold an approval the commit queue will land

On 2026-12-02, approving nodejs/node#65343 and adding commit-queue put
its entry on hold for green CI, though its dossier showed CI=SUCCESS at
the head. Two causes, both in sync's landing gates:

- The CI gate read only cache/ci.json, which covers cq candidates. A
  fresh or re-review entry never has a row there, so its CI always
  counted as not green. It now falls back to the dossier's ci.txt,
  through the same parser the tick uses.
- An approval on a PR that already has commit-queue was held for the
  landing wait and CI. The commit queue lands it, so the entry is done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* nodejs-review-bank: give sessions a scratch folder outside .claude

In the slot run for nodejs/node#67851, the session couldn't write its
probe to the slot's .claude/tmp/, though its allow rule covers the
whole checkout. In dontAsk mode, Claude Code refuses writes under any
.claude/ directory. A headless run confirmed it: the same write to a
folder beside it worked.

slot acquire now creates .review-tmp/ in the slot and adds it to the
clone's info/exclude, which its worktrees share, so the folder never
makes a slot dirty. The run recipes and the session rules use it. The
copied-test recipe's require rewrite changes to ../test/ to match the
new depth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* nodejs-review-bank: show PRs whose stalled label the automation removed

On 2026-12-02 the first sweep target was nodejs/node#52176, which I'd
labeled stalled in July. github-actions removed the label about 10
hours later, so the PR stayed open, and the sweep, knowing only its own
empty ledger, listed it as new. Of the 19 PRs from that pass, 4 lost the
label: 2 because their authors came back, and #52176 and #56287 with no
author activity at all.

sweep now reads each PR's stalled label events. A PR the user labeled
whose label was removed since, with the author still silent, is listed
first as "re-label or close", with when and by whom. To find those
anywhere in the set, it fetches details for every due PR (three GraphQL
calls for 88 PRs), and --batch now limits only how many quiet PRs it
shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* nodejs-review-bank: let the sweep record a close

On 2026-12-02 I closed nodejs/node#52176 from the sweep instead of
labeling it stalled, and sweep mark had no way to record that. Closing
is often the right call: collaborators may close PRs that aren't moving,
and it's quicker for a PR whose stalled label the automation already
removed once, or for spam.

sweep mark <pr> closed records it. The sweep lists only open PRs, so a
closed one drops out, and comes back as REOPENED if it's reopened.
SKILL.md says closing is a valid outcome, and that in a review a close
needs no command, since sync reads it from GitHub.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@nodejs-github-bot
nodejs-github-bot merged commit 42a47ba into nodejs:main Dec 3, 2026
72 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 42a47ba

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue-squash PRs the Commit Queue should land as one squashed commit. http Issues and PRs related to the http subsystem. https Issues and PRs related to the https subsystem. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants