Uh oh!
There was an error while loading. Please reload this page.
stream: avoid duplicated endReadableNT scheduling - #65310
Merged
nodejs-github-bot merged 1 commit intoAug 23, 2026
Conversation
nodejs-github-bot
commented
Aug 15, 2026
Collaborator
Review requested:
|
jasnell
approved these changes
Aug 15, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@## main #65310 +/- ##
==========================================
- Coverage 90.30% 90.12% -0.18%
==========================================
Files 759 752 -7 Lines 248294 251576 +3282 Branches 46860 47263 +403 ==========================================
+ Hits 224220 226737 +2517 - Misses 15516 16178 +662 - Partials 8558 8661 +103
🚀 New features to boost your workflow:
|
jasnell
approved these changes
Aug 15, 2026
Calling read() on an ended stream multiple times before the microtask queue drains scheduled one endReadableNT tick per call, as the only guard was endEmitted, which is set inside the tick itself. A hello-world HTTP server was scheduling it four times per request while dumping the unread request body. Introduce a kEndScheduled flag armed when the tick is scheduled and cleared when it runs. Clearing it unconditionally matters for reused sockets: undestroy() resets endEmitted through the state descriptors but cannot reach this flag, and a stale value would block the 'end' event after a net.Socket reconnect. Signed-off-by: Matteo Collina <hello@matteocollina.com>
ronag
approved these changes
Aug 16, 2026
nodejs-github-bot
commented
Aug 16, 2026
Collaborator
mcollinaforce-pushed
the
stream-dedupe-endreadable-tick
branch
from
August 16, 2026 20:46
4c33258 to
4ccbe5eCompareShogunPanda
approved these changes
Aug 19, 2026
nodejs-github-bot
commented
Aug 19, 2026
Collaborator
Commit Queue failed- Loading data for nodejs/node/pull/65310 ✔ Done loading data for nodejs/node/pull/65310 ----------------------------------- PR info ------------------------------------ Title stream: avoid duplicated endReadableNT scheduling (#65310) Author Matteo Collina <matteo.collina@gmail.com> (@mcollina) Branch mcollina:stream-dedupe-endreadable-tick -> nodejs:main Labels stream, author ready, needs-ci, commit-queue Commits 1 - stream: avoid duplicated endReadableNT scheduling Committers 1 - Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/65310 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/65310 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> -------------------------------------------------------------------------------- ℹ This PR was created on Sat, 15 Aug 2026 20:35:50 GMT ✔ Approvals: 3 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/65310#pullrequestreview-4944843305 ✔ - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/65310#pullrequestreview-4945590565 ✔ - Paolo Insogna (@ShogunPanda) (TSC): https://github.com/nodejs/node/pull/65310#pullrequestreview-4969779696 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2026-08-16T08:13:00Z: https://ci.nodejs.org/job/node-test-pull-request/75878/ - Querying data for job/node-test-pull-request/75878/ ✔ Build data downloaded - Querying failures of job/node-test-commit/90607/ ✔ Data downloaded ✘ 23 failure(s) on the last Jenkins CI run -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/32254812825 |
This comment was marked as outdated.
This comment was marked as outdated.
nodejs-github-bot
commented
Aug 20, 2026
Collaborator
nodejs-github-bot
commented
Aug 21, 2026
Collaborator
Commit Queue failed- Loading data for nodejs/node/pull/65310 ✔ Done loading data for nodejs/node/pull/65310 ----------------------------------- PR info ------------------------------------ Title stream: avoid duplicated endReadableNT scheduling (#65310) Author Matteo Collina <matteo.collina@gmail.com> (@mcollina) Branch mcollina:stream-dedupe-endreadable-tick -> nodejs:main Labels stream, author ready, needs-ci, commit-queue Commits 1 - stream: avoid duplicated endReadableNT scheduling Committers 1 - Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/65310 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/65310 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> -------------------------------------------------------------------------------- ℹ This PR was created on Sat, 15 Aug 2026 20:35:50 GMT ✔ Approvals: 3 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/65310#pullrequestreview-4944843305 ✔ - Robert Nagy (@ronag) (TSC): https://github.com/nodejs/node/pull/65310#pullrequestreview-4945590565 ✔ - Paolo Insogna (@ShogunPanda) (TSC): https://github.com/nodejs/node/pull/65310#pullrequestreview-4969779696 ✘ GitHub CI failed with status: FAILURE ℹ Last Full PR CI on 2026-08-20T23:59:20Z: https://ci.nodejs.org/job/node-test-pull-request/76092/ - Querying data for job/node-test-pull-request/76092/ ✔ Build data downloaded ✘ Last Jenkins CI still running -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/32435803605 |
nodejs-github-bot
commented
Aug 21, 2026
Collaborator
nodejs-github-bot
commented
Aug 21, 2026
Collaborator
nodejs-github-bot
commented
Aug 21, 2026
Collaborator
nodejs-github-bot
commented
Aug 22, 2026
Collaborator
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Aug 23, 2026
Collaborator
Landed in 82babee |
aduh95 pushed a commit
that referenced
this pull request
Aug 25, 2026
Calling read() on an ended stream multiple times before the microtask queue drains scheduled one endReadableNT tick per call, as the only guard was endEmitted, which is set inside the tick itself. A hello-world HTTP server was scheduling it four times per request while dumping the unread request body. Introduce a kEndScheduled flag armed when the tick is scheduled and cleared when it runs. Clearing it unconditionally matters for reused sockets: undestroy() resets endEmitted through the state descriptors but cannot reach this flag, and a stale value would block the 'end' event after a net.Socket reconnect. Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: #65310 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
aduh95 pushed a commit
that referenced
this pull request
Aug 25, 2026
Calling read() on an ended stream multiple times before the microtask queue drains scheduled one endReadableNT tick per call, as the only guard was endEmitted, which is set inside the tick itself. A hello-world HTTP server was scheduling it four times per request while dumping the unread request body. Introduce a kEndScheduled flag armed when the tick is scheduled and cleared when it runs. Clearing it unconditionally matters for reused sockets: undestroy() resets endEmitted through the state descriptors but cannot reach this flag, and a stale value would block the 'end' event after a net.Socket reconnect. Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: #65310 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
aduh95 pushed a commit
that referenced
this pull request
Aug 27, 2026
Calling read() on an ended stream multiple times before the microtask queue drains scheduled one endReadableNT tick per call, as the only guard was endEmitted, which is set inside the tick itself. A hello-world HTTP server was scheduling it four times per request while dumping the unread request body. Introduce a kEndScheduled flag armed when the tick is scheduled and cleared when it runs. Clearing it unconditionally matters for reused sockets: undestroy() resets endEmitted through the state descriptors but cannot reach this flag, and a stale value would block the 'end' event after a net.Socket reconnect. Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: #65310 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
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 freeto 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.
Calling read() on an ended stream multiple times before the microtask queue drains scheduled one endReadableNT tick per call, since the only guard (endEmitted) is set inside the tick itself. A hello-world HTTP server was scheduling it four times per request while dumping the unread request body.
Add a kEndScheduled flag, armed on scheduling and cleared when the tick runs. It must be cleared unconditionally: undestroy() resets endEmitted through the state descriptors but cannot reach this flag, and a stale value would block 'end' after a net.Socket reconnect.
Benchmarks vs main:
streams/finished.jsreadable +10.45% (99.9% confidence), no significant regressions across the streams suite; ~+1-3% on HTTP server benchmarks (10 → 7 nextTicks per request).