http: avoid stream listeners on idle agent sockets#64004
Merged
nodejs-github-bot merged 1 commit intoJun 20, 2026
Conversation
Collaborator
|
Review requested:
|
Member
Author
|
@nodejs/releasers unfortunately, we would need to backport this to node 22.x and 24.x to fix node-fetch@2. |
Member
Author
|
I'm sorry I should have caught this before shipping. |
Renegade334
approved these changes
Jun 19, 2026
Renegade334
left a comment
Member
There was a problem hiding this comment.
Side-note: I had a cursory look for guidance on Node.js internals managing EventEmitter events on emitter-derived Node.js classes, and found none. My feeling is that we don't ordinarily consider changes related to internally-managed event listeners to be semver-major, even though they're publicly observable. Maybe we should elucidate what our stance is, and make it explicit in the EventEmitter documentation?
Contributor
|
Fast-track has been requested by @Renegade334. Please 👍 to approve. |
anonrig
approved these changes
Jun 19, 2026
2 tasks
bjohansebas
approved these changes
Jun 19, 2026
Collaborator
jasnell
approved these changes
Jun 19, 2026
Collaborator
Signed-off-by: Matteo Collina <[email protected]>
8d8919c to
0d62f61
Compare
ronag
approved these changes
Jun 20, 2026
Collaborator
ronag
approved these changes
Jun 20, 2026
Collaborator
Collaborator
Commit Queue failed- Loading data for nodejs/node/pull/64004 ✔ Done loading data for nodejs/node/pull/64004 ----------------------------------- PR info ------------------------------------ Title http: avoid stream listeners on idle agent sockets (#64004) Author Matteo Collina <[email protected]> (@mcollina) Branch mcollina:fix-http-agent-free-socket-onread -> nodejs:main Labels http, fast-track, author ready, needs-ci, lts-watch-v22.x, lts-watch-v24.x Commits 1 - http: avoid stream listeners on idle agent sockets Committers 1 - Matteo Collina <[email protected]> PR-URL: https://github.com/nodejs/node/pull/64004 Fixes: https://github.com/nodejs/node/issues/63989 Reviewed-By: René <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Robert Nagy <[email protected]> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/64004 Fixes: https://github.com/nodejs/node/issues/63989 Reviewed-By: René <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Robert Nagy <[email protected]> -------------------------------------------------------------------------------- ℹ This PR was created on Fri, 19 Jun 2026 14:49:05 GMT ✔ Approvals: 4 ✔ - René (@Renegade334): https://github.com/nodejs/node/pull/64004#pullrequestreview-4533753549 ✔ - Yagiz Nizipli (@anonrig) (TSC): https://github.com/nodejs/node/pull/64004#pullrequestreview-4533914964 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/64004#pullrequestreview-4535587792 ✔ - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/64004#pullrequestreview-4536884413 ℹ This PR is being fast-tracked ✘ This PR needs to wait 25 more hours to land (or 0 hours if there is 1 more approval (👍) of the fast-track request from collaborators). ✔ Last GitHub CI successful ℹ Last Full PR CI on 2026-06-20T10:50:37Z: https://ci.nodejs.org/job/node-test-pull-request/74300/ - Querying data for job/node-test-pull-request/74300/ ✔ Build data downloaded ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/27873727043 |
Collaborator
|
Landed in 57a4932 |
aduh95
pushed a commit
that referenced
this pull request
Jun 20, 2026
Signed-off-by: Matteo Collina <[email protected]> PR-URL: #64004 Fixes: #63989 Reviewed-By: René <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Robert Nagy <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #63989
The response-queue-poisoning guard added to idle
http.Agentsockets used a public'data'listener. That madenode-fetch@2observesocket.listenerCount('data') > 0during response close and report falseERR_STREAM_PREMATURE_CLOSEerrors.This changes the idle-socket guard to use the socket handle's internal
onreadhook while the socket is in the free pool, restoring the normal stream read callback when the socket is reused. The guard still destroys sockets that receive unsolicited data while idle, but it no longer adds public stream listeners.