node/lib/internal/webstreams
sangwook dc57173003
stream: fix Writable.toWeb() hang on synchronous drain
A race condition in the Writable.toWeb() adapter caused the stream
to hang if the underlying Node.js Writable emitted a 'drain' event
synchronously during a write() call. This often happened when
highWaterMark was set to 0.

By checking writableNeedDrain immediately after a backpressured write,
the adapter now correctly detects if the stream has already drained,
resolving the backpressure promise instead of waiting indefinitely
for an event that has already occurred.

Fixes: https://github.com/nodejs/node/issues/61145
Signed-off-by: sangwook <rewq5991@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/61197
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-06-18 21:12:33 +01:00
..
adapters.js stream: fix Writable.toWeb() hang on synchronous drain 2026-06-18 21:12:33 +01:00
compression.js stream: allow shared array buffer sources in writable webstream adapter 2026-05-07 15:41:39 +02:00
encoding.js
queuingstrategies.js stream: remove duplicated utility 2026-05-07 15:41:50 +02:00
readablestream.js lib: narrow ReadableStreamBYOBRequest.view return type to Uint8Array 2026-06-18 00:15:51 +02:00
transfer.js
transformstream.js stream: remove duplicated utility 2026-05-07 15:41:50 +02:00
util.js stream: remove unnecessary check 2026-06-18 00:15:54 +02:00
writablestream.js stream: remove duplicated utility 2026-05-07 15:41:50 +02:00