http: avoid stream listeners on idle agent sockets#64004
Conversation
|
Review requested:
|
|
@nodejs/releasers unfortunately, we would need to backport this to node 22.x and 24.x to fix node-fetch@2. |
|
I'm sorry I should have caught this before shipping. |
Renegade334
left a comment
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?
|
Fast-track has been requested by @Renegade334. Please 👍 to approve. |
Signed-off-by: Matteo Collina <hello@matteocollina.com>
8d8919c to
0d62f61
Compare
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 <matteo.collina@gmail.com> (@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 <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/64004 Fixes: https://github.com/nodejs/node/issues/63989 Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/64004 Fixes: https://github.com/nodejs/node/issues/63989 Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> -------------------------------------------------------------------------------- ℹ 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 |
|
Landed in 57a4932 |
…egression
With authz enabled the portal showed "Failed to load platform details"
and broken catalog views: the catalog's internal call to the permission
backend (node-fetch@2 via cross-fetch -> /api/permission/authorize)
failed with ERR_STREAM_PREMATURE_CLOSE, surfacing as a 500 on
/api/catalog/entities/by-refs.
Root cause is the Node 22.23.0 / 24.17.0 security fix for CVE-2026-48931
("response queue poisoning in http.Agent"), which changed keep-alive
socket-reuse behaviour and exposes a latent node-fetch@2 bug (its
malformed-chunked-response detector throws false-positive premature-close
on reused pooled sockets). The base image node:22-bookworm-slim floated
to 22.23.0, which is why this appeared in newly built images. Pin to
22.22 (last release before the regression) until the Node 22.x patch
with nodejs/node#64004 ships.
- backstage/backstage#34651
- nodejs/node#63989
- nodejs/node#64004
Also drop the duplicated helmet/cors/compression from the root router
configure block — applyDefaults() already applies them, so they ran
twice; keep only the IDP token middleware before applyDefaults().
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Is this also backported to 22 and 24 series, and a release created for both? |
@xnox, this unfortunately didn't land as a patch release. I see it's bundled in the |
…egression
With authz enabled the portal showed "Failed to load platform details"
and broken catalog views: the catalog's internal call to the permission
backend (node-fetch@2 via cross-fetch -> /api/permission/authorize)
failed with ERR_STREAM_PREMATURE_CLOSE, surfacing as a 500 on
/api/catalog/entities/by-refs.
Root cause is the Node 22.23.0 / 24.17.0 security fix for CVE-2026-48931
("response queue poisoning in http.Agent"), which changed keep-alive
socket-reuse behaviour and exposes a latent node-fetch@2 bug (its
malformed-chunked-response detector throws false-positive premature-close
on reused pooled sockets). The base image node:22-bookworm-slim floated
to 22.23.0, which is why this appeared in newly built images. Pin to
22.22 (last release before the regression) until the Node 22.x patch
with nodejs/node#64004 ships.
- backstage/backstage#34651
- nodejs/node#63989
- nodejs/node#64004
Also drop the duplicated helmet/cors/compression from the root router
configure block — applyDefaults() already applies them, so they ran
twice; keep only the IDP token middleware before applyDefaults().
Signed-off-by: Kavith Lokuhewage <kaviththiranga@gmail.com>
Notable changes: buffer: * (SEMVER-MINOR) increase Buffer.poolSize default to 64 KiB (Matteo Collina) nodejs#63597 crypto: * update root certificates to NSS 3.123.1 (Node.js GitHub Bot) nodejs#63527 * (SEMVER-MINOR) align key argument names in docs and error messages (Filip Skokan) nodejs#62527 * (SEMVER-MINOR) accept key data in crypto.diffieHellman() and cleanup DH jobs (Filip Skokan) nodejs#62527 * (SEMVER-MINOR) add TurboSHAKE and KangarooTwelve Web Cryptography algorithms (Filip Skokan) nodejs#62183 http: * http: avoid stream listeners on idle agent sockets (Matteo Collina) nodejs#64004 * (SEMVER-MINOR) add writeInformation to send arbitrary 1xx status codes (Tim Perry) nodejs#63155 inspector: * (SEMVER-MINOR) expose precise coverage start to JS runtime (sangwook) nodejs#63079 stream: * stream: Revert noop pause/resume on destroyed streams" (Stewart X Addison) nodejs#63834 PR-URL: nodejs#64062
If you expand all comments/events on #63989 the "88 remaining items" you can see a huge surge of people reverting/blocking tracking point releases and pinning back to previous v24 and v22 point releases because of this regression. Thus the longer this fix is not out; the more people are pinning to older vulnerable node; and likely will be stuck on it - as very often when such pins are introduced, people forget to add a gate test and continuously attempt to upgrade. |
Notable changes: buffer: * (SEMVER-MINOR) increase Buffer.poolSize default to 64 KiB (Matteo Collina) #63597 crypto: * update root certificates to NSS 3.123.1 (Node.js GitHub Bot) #63527 * (SEMVER-MINOR) align key argument names in docs and error messages (Filip Skokan) #62527 * (SEMVER-MINOR) accept key data in crypto.diffieHellman() and cleanup DH jobs (Filip Skokan) #62527 * (SEMVER-MINOR) add TurboSHAKE and KangarooTwelve Web Cryptography algorithms (Filip Skokan) #62183 http: * http: avoid stream listeners on idle agent sockets (Matteo Collina) #64004 * (SEMVER-MINOR) add writeInformation to send arbitrary 1xx status codes (Tim Perry) #63155 inspector: * (SEMVER-MINOR) expose precise coverage start to JS runtime (sangwook) #63079 stream: * stream: Revert noop pause/resume on destroyed streams" (Stewart X Addison) #63834 PR-URL: #64062
Notable changes: buffer: * (SEMVER-MINOR) increase Buffer.poolSize default to 64 KiB (Matteo Collina) #63597 crypto: * update root certificates to NSS 3.123.1 (Node.js GitHub Bot) #63527 * (SEMVER-MINOR) align key argument names in docs and error messages (Filip Skokan) #62527 * (SEMVER-MINOR) accept key data in crypto.diffieHellman() and cleanup DH jobs (Filip Skokan) #62527 * (SEMVER-MINOR) add TurboSHAKE and KangarooTwelve Web Cryptography algorithms (Filip Skokan) #62183 http: * http: avoid stream listeners on idle agent sockets (Matteo Collina) #64004 * (SEMVER-MINOR) add writeInformation to send arbitrary 1xx status codes (Tim Perry) #63155 inspector: * (SEMVER-MINOR) expose precise coverage start to JS runtime (sangwook) #63079 stream: * stream: Revert noop pause/resume on destroyed streams" (Stewart X Addison) #63834 PR-URL: #64062
…egression (#649) * fix(backend): pin Node to 22.22 to avoid node-fetch premature-close regression With authz enabled the portal showed "Failed to load platform details" and broken catalog views: the catalog's internal call to the permission backend (node-fetch@2 via cross-fetch -> /api/permission/authorize) failed with ERR_STREAM_PREMATURE_CLOSE, surfacing as a 500 on /api/catalog/entities/by-refs. Root cause is the Node 22.23.0 / 24.17.0 security fix for CVE-2026-48931 ("response queue poisoning in http.Agent"), which changed keep-alive socket-reuse behaviour and exposes a latent node-fetch@2 bug (its malformed-chunked-response detector throws false-positive premature-close on reused pooled sockets). The base image node:22-bookworm-slim floated to 22.23.0, which is why this appeared in newly built images. Pin to 22.22 (last release before the regression) until the Node 22.x patch with nodejs/node#64004 ships. - backstage/backstage#34651 - nodejs/node#63989 - nodejs/node#64004 Also drop the duplicated helmet/cors/compression from the root router configure block — applyDefaults() already applies them, so they ran twice; keep only the IDP token middleware before applyDefaults(). Signed-off-by: Kavith Lokuhewage <kaviththiranga@gmail.com> * chore: add changeset file for node version pin in backend pkg Signed-off-by: Kavith Lokuhewage <kaviththiranga@gmail.com> --------- Signed-off-by: Kavith Lokuhewage <kaviththiranga@gmail.com>
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.