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