stream: preserve mutable chunks in Web Stream adapters - #64579
seungwoo505 wants to merge 4 commits into
Conversation
|
Review requested:
|
| @@ -1260,4 +1262,5 @@ module.exports = { | |||
| validateHeaderName, | |||
| validateHeaderValue, | |||
| OutgoingMessage, | |||
| outgoingMessagePrototypeWrite, | |||
There was a problem hiding this comment.
The Web Streams adapter uses this export to compare the active write() method with the original OutgoingMessage.prototype.write.
This distinction preserves the native validation behavior without applying it to overridden write() implementations.
The reference is captured here so a later prototype monkey-patch is not mistaken for the original method.
97f5318 to
c08321a
Compare
|
Hi @bjohansebas, just a friendly follow-up on this. |
|
Sorry for the radio silence. Can you rebase again? |
|
Sorry, I just saw your message. |
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>
Rely on native stream validation after copying array buffer views. Keep object-mode writes on their existing completion timing, and remove adapter-only HTTP detection and prototype capture. Signed-off-by: seungwoo <zoozoo1302@gmail.com>
Remove overlapping override coverage. Verify object-mode writes settle independently of native callbacks. Exercise the Writable.toWeb(Duplex) path and keep native HTTP validation coverage. Assisted-by: Codex Signed-off-by: seungwoo <zoozoo1302@gmail.com>
c08321a to
062b9a0
Compare
|
Hi @mcollina, I’ve rebased the PR onto the latest main and resolved the conflicts. |
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 -j4 test(full test suite passed)git diff --checkFixes: #64549