node/lib/internal/webstreams
Matteo Collina cc29696acf
stream: fix Writable.toWeb() desiredSize for non-object-mode
Writable.toWeb() used a plain { highWaterMark } as the queuing
strategy for non-object-mode streams, which meant no size function
was provided. The WritableStream defaulted to counting each chunk
as size 1, so desiredSize was incorrect (e.g., a 3-byte Uint8Array
was counted as size 1 instead of 3).

Add a size() function to the strategy that mirrors how the Node.js
stream computes chunk length: byteLength for typed arrays, length
for strings/buffers, falling back to 1.

Fixes: https://github.com/nodejs/node/issues/56269
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/62986
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-06-22 08:58:18 +02:00
..
adapters.js stream: fix Writable.toWeb() desiredSize for non-object-mode 2026-06-22 08:58:18 +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 tools: enforce iterator result property order 2026-06-20 17:50:56 +02:00
transfer.js lib: replace createDeferredPromise util with Promise.withResolvers 2024-10-19 10:13:58 +02:00
transformstream.js stream: only pass the expected number of parameters to callbacks 2026-06-18 10:11:23 +02:00
util.js stream: reduce allocations on WHATWG streams hot paths 2026-06-20 16:58:28 +02:00
writablestream.js stream: reduce allocations on WHATWG streams hot paths 2026-06-20 16:58:28 +02:00