Skip to content

stream: wait for push writer end fallback to drain#63503

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-iter-push-writer-end-resolve
Open

stream: wait for push writer end fallback to drain#63503
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-iter-push-writer-end-resolve

Conversation

@trivikr
Copy link
Copy Markdown
Member

@trivikr trivikr commented May 23, 2026

Fixes an issue in node:stream/iter where push() writer end() could
resolve before buffered data was consumed when called after endSync()
returned -1.

endSync() already transitions the queue to closing when data remains
buffered. A subsequent async end() now keeps waiting for that closing
state to drain, and reuses any existing pending end promise.

duplex() channel close now only signals EOF synchronously instead of
awaiting that drain, since the peer may not start reading until after
close() resolves.

Fixes: #63502


Assisted-by: openai:gpt-5.5

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem. labels May 23, 2026
When endSync() returns -1 after buffered writes, a follow-up end()
should stay pending until the readable side drains the queued data.

Do not make duplex channel close() wait for that drain, since close()
only needs to signal EOF to the peer. Waiting there can deadlock when
the peer starts reading only after close() resolves.

Fixes: nodejs#63502

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.5
@trivikr trivikr force-pushed the stream-iter-push-writer-end-resolve branch from 7fa1d26 to cee2067 Compare May 23, 2026 06:50
@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.13%. Comparing base (8d3245e) to head (cee2067).

Files with missing lines Patch % Lines
lib/internal/streams/iter/push.js 62.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63503      +/-   ##
==========================================
- Coverage   90.14%   90.13%   -0.02%     
==========================================
  Files         718      718              
  Lines      227984   227987       +3     
  Branches    42835    42841       +6     
==========================================
- Hits       205522   205486      -36     
- Misses      14235    14284      +49     
+ Partials     8227     8217      -10     
Files with missing lines Coverage Δ
lib/internal/streams/iter/duplex.js 96.35% <100.00%> (-0.11%) ⬇️
lib/internal/streams/iter/push.js 92.01% <62.50%> (-0.20%) ⬇️

... and 28 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.

@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR. stream Issues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stream/iter: push writer.end() resolves before readable drains buffered data

2 participants