Skip to content

stream: avoid duplicate writes in toWritable#63360

Open
trivikr wants to merge 2 commits into
nodejs:mainfrom
trivikr:stream-iter-towritable-write
Open

stream: avoid duplicate writes in toWritable#63360
trivikr wants to merge 2 commits 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

@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
@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

Codecov Report

❌ Patch coverage is 87.14286% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.04%. Comparing base (8c6e39e) to head (52ffb94).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/streams/iter/classic.js 80.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63360      +/-   ##
==========================================
- Coverage   90.05%   90.04%   -0.02%     
==========================================
  Files         714      714              
  Lines      225564   225628      +64     
  Branches    42660    42667       +7     
==========================================
+ Hits       203134   203168      +34     
- Misses      14209    14248      +39     
+ Partials     8221     8212       -9     
Files with missing lines Coverage Δ
lib/internal/streams/iter/push.js 92.20% <100.00%> (+0.12%) ⬆️
lib/internal/streams/iter/types.js 100.00% <100.00%> (ø)
lib/internal/streams/iter/classic.js 88.91% <80.00%> (-0.54%) ⬇️

... and 47 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 self-assigned this May 16, 2026
trivikr added 2 commits May 16, 2026 08:10
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 <[email protected]>
Assisted-by: openai:gpt-5.5
@trivikr trivikr force-pushed the stream-iter-towritable-write branch from a03df89 to 52ffb94 Compare May 16, 2026 15:12
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label 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. 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: toWritable() duplicates writes when writeSync() returns false after accepting chunk

2 participants