Skip to content

stream: uncork fromWritable writev on chunk error#63295

Open
trivikr wants to merge 2 commits into
nodejs:mainfrom
trivikr:stream-iter-writable-corked
Open

stream: uncork fromWritable writev on chunk error#63295
trivikr wants to merge 2 commits into
nodejs:mainfrom
trivikr:stream-iter-writable-corked

Conversation

@trivikr
Copy link
Copy Markdown
Member

@trivikr trivikr commented May 13, 2026

Fixes fromWritable().writev() leaving the wrapped classic Writable
corked when conversion of a later chunk throws.

Previously, writev() called writable.cork() before converting all
chunks. If toUint8Array() threw, for example with
writer.writev([new Uint8Array([1]), 42]), execution skipped
writable.uncork() and left writable.writableCorked === 1.

This wraps the corked batch write in try/finally so the internal cork
is always released, and adds a regression test for the invalid later
chunk case.

Fixes: #63294


Assisted-by: openai:gpt-5.5

Ensure fromWritable().writev() uncorks the wrapped Writable when
converting a later chunk throws. This prevents an internal cork from
leaking after ERR_INVALID_ARG_TYPE.

Fixes: nodejs#63294

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 13, 2026
@trivikr trivikr self-assigned this May 13, 2026
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label May 13, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

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

Files with missing lines Patch % Lines
lib/internal/streams/iter/classic.js 90.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63295      +/-   ##
==========================================
- Coverage   90.05%   90.05%   -0.01%     
==========================================
  Files         714      714              
  Lines      225247   225261      +14     
  Branches    42578    42578              
==========================================
+ Hits       202842   202852      +10     
- Misses      14181    14187       +6     
+ Partials     8224     8222       -2     
Files with missing lines Coverage Δ
lib/internal/streams/iter/classic.js 89.17% <90.00%> (-0.18%) ⬇️

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

@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
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: fromWritable().writev() leaves Writable corked when chunk validation throws

3 participants