stream: fix pipeTo to defer writes per WHATWG spec · nodejs/node@ea2df2a · GitHub
Skip to content

Commit ea2df2a

Browse files
mcollinaaduh95
authored andcommitted
stream: fix pipeTo to defer writes per WHATWG spec
The WHATWG Streams spec requires that pipeTo's chunk handling must queue a microtask before calling the write algorithm. This ensures that enqueue() does not synchronously trigger writes. Previously, PipeToReadableStreamReadRequest[kChunk] would synchronously call writableStreamDefaultWriterWrite(), which violated the spec and caused the WPT test "enqueue() must not synchronously call write algorithm" to fail. Fix by wrapping the write operation in queueMicrotask(), which defers it to the next microtask as required by the spec. Refs: whatwg/streams#1243 PR-URL: #61800 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Mattias Buelens <mattias@buelens.com>
1 parent 9ddd1a9 commit ea2df2a

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

lib/internal/webstreams/readablestream.js

Lines changed: 8 additions & 3 deletions

test/wpt/status/streams.json

Lines changed: 0 additions & 8 deletions

0 commit comments

Comments
 (0)