Skip to content

stream: avoid duplicate writes in toWritable#63360

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-iter-towritable-write
Open

stream: avoid duplicate writes in toWritable#63360
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-iter-towritable-write

Conversation

@trivikr
Copy link
Copy Markdown
Member

@trivikr trivikr commented May 16, 2026

toWritable() currently treats writeSync() / writevSync() returning
false as meaning the data was not accepted and retries through the async
writer method.

For PushWriter with backpressure: 'block', false can instead mean the
chunk was accepted and backpressure is active. Retrying through
write() / writev() writes the same data twice.

This updates the adapter to recognize that accepted-backpressure case and wait
for drain instead of retrying the chunk.

Fixes: #63359


Assisted-by: openai:gpt-5.5

PushWriter can return false after accepting a chunk when block
backpressure is active. Teach the classic Writable adapter to treat
that case as accepted backpressure instead of retrying through the
async write path.

Fixes: nodejs#63359

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
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 16, 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. stream Issues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stream/iter: toWritable() duplicates writes when writeSync() returns false after accepting chunk

2 participants