stream: preserve mutable chunks in Web Stream adapters#64579
Open
seungwoo505 wants to merge 2 commits into
Open
stream: preserve mutable chunks in Web Stream adapters#64579seungwoo505 wants to merge 2 commits into
seungwoo505 wants to merge 2 commits into
Conversation
Wait for native write callbacks when they can safely represent chunk consumption. For Duplex streams, corked writes, and custom or legacy write methods, pass private BufferSource copies to preserve completion timing. Coordinate callback completion with backpressure, aborts, and stream errors so a settled Web Streams write no longer exposes mutable bytes still retained by the native stream. Preserve native HTTP validation and SharedArrayBuffer backing when fallback copies are required. Signed-off-by: seungwoo <zoozoo1302@gmail.com>
Cover native callback completion, fallback copies, aborts, and error propagation for mutable BufferSource chunks passed to Node.js Web Streams adapters. Verify HTTP validation, SharedArrayBuffer backing, and Duplex and compression paths. Signed-off-by: seungwoo <zoozoo1302@gmail.com>
Collaborator
|
Review requested:
|
seungwoo505
marked this pull request as ready for review
July 18, 2026 16:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a Node.js writable is converted with
Writable.toWeb(), the Web Streamswrite()promise can currently settle as soon as the nativewrite()callreturns
true. That return value only represents backpressure, so the nativestream may still retain the supplied mutable BufferSource. Reusing the buffer
after awaiting the Web write can therefore change bytes that have not yet been
consumed.
This change:
unmodified
Writable;drain, aborts, and native streamerrors;
and legacy write paths where waiting for a callback would change existing
completion behavior;
The original native
Writable.prototype.writeandOutgoingMessage.prototype.writemethods are captured so patched methods andaccessors are classified and invoked consistently.
Validation included:
make -j4git diff --checkFixes: #64549