node/lib/internal/webstreams
sangwook 217338e18b
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-05-23 00:05:42 +02:00
..
adapters.js stream: fix Writable.toWeb() hang on synchronous drain 2026-05-23 00:05:42 +02:00
compression.js stream: allow shared array buffer sources in writable webstream adapter 2026-05-05 16:19:27 +02:00
encoding.js stream: handle undefined chunks correctly in decode stream 2024-09-30 17:54:43 +00:00
queuingstrategies.js stream: remove duplicated utility 2026-05-05 16:19:52 +02:00
readablestream.js lib: narrow ReadableStreamBYOBRequest.view return type to Uint8Array 2026-05-19 14:08:19 +02:00
transfer.js lib: replace createDeferredPromise util with Promise.withResolvers 2024-10-19 10:13:58 +02:00
transformstream.js stream: remove duplicated utility 2026-05-05 16:19:52 +02:00
util.js stream: remove unnecessary check 2026-05-19 14:08:24 +02:00
writablestream.js stream: remove duplicated utility 2026-05-05 16:19:52 +02:00