Skip to content

stream: avoid retrying accepted pipeTo writes#63297

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-ter-pipeto-write
Open

stream: avoid retrying accepted pipeTo writes#63297
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:stream-ter-pipeto-write

Conversation

@trivikr
Copy link
Copy Markdown
Member

@trivikr trivikr commented May 14, 2026

pipeTo() treated writeSync() / writevSync() returning false as a
failed sync write and retried the same chunk(s) through the async path.

That is incorrect for PushWriter with backpressure: 'block', where
false means the data was accepted but the writer is now backpressured. This
caused duplicated output such as abcdcd instead of abcd, and abbb
instead of ab.

This updates pipeTo() to detect that internal writer case and wait for drain
instead of retrying accepted data. It also adds regression coverage for both
the single-chunk writeSync() path and the multi-chunk writevSync() path.

Fixes: #63296


Assisted-by: openai:gpt-5.5

PushWriter in block backpressure mode can return false from writeSync()
and writevSync() after accepting data. Treat that false return as
backpressure and wait for drain instead of retrying the same chunks
asynchronously.

Fixes: nodejs#63296

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

@trivikr trivikr self-assigned this May 14, 2026
@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 14, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.05%. Comparing base (c24e552) to head (921ab42).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/streams/iter/pull.js 87.50% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #63297   +/-   ##
=======================================
  Coverage   90.05%   90.05%           
=======================================
  Files         714      714           
  Lines      225247   225289   +42     
  Branches    42578    42594   +16     
=======================================
+ Hits       202842   202891   +49     
+ Misses      14181    14175    -6     
+ Partials     8224     8223    -1     
Files with missing lines Coverage Δ
lib/internal/streams/iter/push.js 92.03% <100.00%> (+0.63%) ⬆️
lib/internal/streams/iter/types.js 100.00% <100.00%> (ø)
lib/internal/streams/iter/pull.js 85.23% <87.50%> (+0.07%) ⬆️

... 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 14, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 14, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@trivikr trivikr added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 14, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. 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: pipeTo retries accepted PushWriter writes under block backpressure

3 participants