René
9cae81932c
stream: allow shared array buffer sources in writable webstream adapter
...
Refs: https://github.com/nodejs/node/pull/61913
Signed-off-by: Renegade334 <contact.9a5d6388@renegade334.me.uk >
PR-URL: https://github.com/nodejs/node/pull/62163
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
2026-04-13 15:42:29 +00:00
sangwook
20cacec5c6
stream: fix writev unhandled rejection in fromWeb
...
When using Duplex.fromWeb() or Writable.fromWeb() with cork()/uncork(),
writes are batched into _writev(). If destroy() is called in the same
microtask, the underlying WritableStream writer gets aborted, causing
SafePromiseAll() to reject with a non-array value (e.g. an AbortError).
The done() callback in _writev() of both fromWeb adapter functions
unconditionally called error.filter(), assuming the value was always an
array. This caused a TypeError that became an unhandled rejection,
crashing the process.
Fix by separating the resolve and reject handlers of SafePromiseAll:
use () => done() on the resolve path (all writes succeeded, no error)
and done on the reject path (error passed directly to callback).
Fixes: https://github.com/nodejs/node/issues/62199
Signed-off-by: sangwook <rewq5991@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/62297
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk >
2026-04-10 20:39:49 +00:00
René
ac6375417a
stream: promote DEP0201 to runtime deprecation
...
PR-URL: https://github.com/nodejs/node/pull/62173
Refs: https://github.com/nodejs/node/pull/61632
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2026-03-17 13:38:50 +00:00
Filip Skokan
3725bd2145
stream: fix brotli error handling in web compression streams
...
Convert brotli decompression errors to TypeError to match the
Compression Streams spec, by extending handleKnownInternalErrors()
in the adapters layer to recognize brotli error codes.
This replaces the manual error event handler on DecompressionStream
which was redundant with the adapter's built-in error propagation.
PR-URL: https://github.com/nodejs/node/pull/62107
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Mattias Buelens <mattias@buelens.com >
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk >
2026-03-06 22:08:57 +00:00
Filip Skokan
7991cd2a71
stream: improve Web Compression spec compliance
...
Pass rejectGarbageAfterEnd: true to createInflateRaw() and
createBrotliDecompress(), matching the behavior already in place
for deflate and gzip. The Compression Streams spec treats any
data following a valid compressed payload as an error.
When the underlying Node.js stream throws synchronously from
write() (e.g. zlib rejects an invalid chunk type), destroy the
stream so that the readable side is also errored. Without this,
the readable side hangs forever waiting for data that will never
arrive.
Introduce a kValidateChunk callback option in the webstreams
adapter layer. Compression streams use this to validate that
chunks are BufferSource instances not backed by SharedArrayBuffer,
replacing the previous monkey-patching of the underlying
handle's write method.
Unskip WPT compression bad-chunks tests which now run instead of
hang and mark the remaining expected failures.
PR-URL: https://github.com/nodejs/node/pull/62107
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Mattias Buelens <mattias@buelens.com >
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk >
2026-03-06 22:08:56 +00:00
조수민
cb6ff03cc5
stream: accept ArrayBuffer in CompressionStream and DecompressionStream
...
PR-URL: https://github.com/nodejs/node/pull/61913
Fixes: https://github.com/nodejs/node/issues/43433
Reviewed-By: Mattias Buelens <mattias@buelens.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Jason Zhang <xzha4350@gmail.com >
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2026-03-02 23:15:09 +00:00
René
04946a7a8c
stream: rename Duplex.toWeb() type option to readableType
...
PR-URL: https://github.com/nodejs/node/pull/61632
Refs: https://github.com/nodejs/node/pull/58664
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Mattias Buelens <mattias@buelens.com >
2026-02-11 02:15:43 +00:00
René
5d39030b2e
stream: export namespace object from internal end-of-stream module
...
PR-URL: https://github.com/nodejs/node/pull/61455
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Mattias Buelens <mattias@buelens.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
2026-01-23 11:47:27 +00:00
Michaël Zasso
10837e33b0
lib,test: fix jsdoc comments
...
To prepare for eslint-plugin-jsdoc update.
Refs: https://github.com/nodejs/node/pull/60535
PR-URL: https://github.com/nodejs/node/pull/60870
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2025-11-30 19:14:12 +01:00
Hans Klunder
33b1574cbf
lib: add support for readable byte streams to .toWeb()
...
Add support for the creation of ReadableByteStream to Readable.toWeb()
and Duplex.toWeb()
This enables the use of .getReader({ mode: "byob" }) on
e.g. socket().toWeb()
Refs: https://github.com/nodejs/node/issues/56004#issuecomment-2908265316
Refs: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API/Using_readable_byte_streams
PR-URL: https://github.com/nodejs/node/pull/58664
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: Mattias Buelens <mattias@buelens.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-11-16 06:51:24 +00:00
James M Snell
85c0f7aef3
lib: fixup more incorrect ERR_INVALID_ARG_VALUE uses
...
PR-URL: https://github.com/nodejs/node/pull/57177
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2025-02-24 23:23:32 +00:00
Yagiz Nizipli
bb8cc65edb
lib: replace createDeferredPromise util with Promise.withResolvers
...
PR-URL: https://github.com/nodejs/node/pull/54836
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2024-10-19 10:13:58 +02:00
jakecastelli and Jason Zhang
55f70ee178
lib: remove unnecessary async
...
Co-authored-by: Jason Zhang <xzha4350@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/54829
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
2024-09-14 14:31:29 +00:00
Fedor Indutny
78150f3e9c
lib: fix unhandled errors in webstream adapters
...
WebStream's Readable controller does not tolerate `.close()` being
called after an `error`. However, when wrapping a Node's Readable stream
it is possible that the sequence of events leads to `finished()`'s
callback being invoked after such `error`.
In order to handle this, in this change we call the `finished()` handler
earlier when controller is canceled, and always handle this as an error
case.
Fix: https://github.com/nodejs/node/issues/54205
PR-URL: https://github.com/nodejs/node/pull/54206
Fixes: https://github.com/nodejs/node/issues/54205
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Mattias Buelens <mattias@buelens.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2024-08-06 18:34:35 +00:00
Jason
261e88e269
stream: use ByteLengthQueuingStrategy when not in objectMode
...
Fixes: https://github.com/nodejs/node/issues/46347
PR-URL: https://github.com/nodejs/node/pull/48847
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2024-05-12 19:24:43 +02:00
Antoine du Hamel
231548b5cf
lib: enforce ASCII order in error code imports
...
PR-URL: https://github.com/nodejs/node/pull/52625
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
2024-04-23 17:05:38 +00:00
Antoine du Hamel
a596af0819
tools: add lint rule to keep primordials in ASCII order
...
PR-URL: https://github.com/nodejs/node/pull/52592
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
2024-04-21 16:53:08 +00:00
Filip Skokan
2aff5cf638
stream: yield expected Error class on zlib errors
...
PR-URL: https://github.com/nodejs/node/pull/50712
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2023-11-19 07:36:30 +00:00
Aras Abbasi
83e6350b82
errors: improve hideStackFrames
...
PR-URL: https://github.com/nodejs/node/pull/49990
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2023-11-11 16:25:08 +00:00
Antoine du Hamel
fe514bf960
lib: enforce use of trailing commas for functions
...
PR-URL: https://github.com/nodejs/node/pull/46629
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
2023-02-14 18:45:16 +01:00
Deokjin Kim
979ec87665
stream: refactor to use validateFunction
...
PR-URL: https://github.com/nodejs/node/pull/46007
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2023-01-01 06:33:41 +00:00
Debadree Chatterjee
2ec418984b
lib: allow Writeable.toWeb() to work on http.Outgoing message
...
Attempted to fix the issue by watering down the condition being
checked in internal/streams/utils isWritableNodeStream utility
Fixes: https://github.com/nodejs/node/issues/44188
PR-URL: https://github.com/nodejs/node/pull/45642
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2022-12-10 17:06:40 +00:00
Yagiz Nizipli
ea92ca1484
stream: add primordials to adapters
...
PR-URL: https://github.com/nodejs/node/pull/45511
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2022-11-20 23:30:59 +00:00
Kohei Ueno
70305bbe42
stream: fix typo in adapters.js ( #45515 )
...
`isReadableNodestream` -> `isReadableNodeStream`
PR-URL: https://github.com/nodejs/node/pull/45515
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-11-19 13:10:44 +01:00
Yagiz Nizipli
770efeab6d
stream: add fast path for utf8
...
PR-URL: https://github.com/nodejs/node/pull/45483
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
2022-11-18 16:03:25 +00:00
David Halls
538d8ce106
stream: don't push null from closed promise #42694
...
closed promise is subscribed to first so will be
resolved first, before any read promise.
This causes data after EOF error to be thrown.
Remove the push null from the closed promise handler.
The push null gets done from the read handler
when it detects done.
PR-URL: https://github.com/nodejs/node/pull/45026
Fixes: https://github.com/nodejs/node/issues/42694
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-10-22 17:27:37 +00:00
Antoine du Hamel
ce639629dd
lib: use safe Promise alternatives when available
...
PR-URL: https://github.com/nodejs/node/pull/43476
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
2022-08-27 11:37:01 +02:00
txxnano
99b109f7f3
stream: initial approach to include strategy options on Readable.toWeb()
...
PR-URL: https://github.com/nodejs/node/pull/43515
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-07-13 11:14:38 +01:00
LiviaMedeiros
a0178a1169
stream: use kEmptyObject
...
PR-URL: https://github.com/nodejs/node/pull/43159
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-06-11 12:18:14 +02:00
Xuguang Mei
54bc3c9afa
stream: use .chunk when calling adapters's writev
...
Fix: https://github.com/nodejs/node/issues/42157
PR-URL: https://github.com/nodejs/node/pull/42161
Fixes: https://github.com/nodejs/node/issues/42157
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2022-03-03 04:53:59 +00:00
Rich Trott
29f714b152
lib,tools: remove empty lines between JSDoc tags
...
This is in preparation for enabling a recommended JSDoc lint rule.
PR-URL: https://github.com/nodejs/node/pull/41147
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2021-12-19 05:30:09 +00:00
Rich Trott
88dd9724b0
lib: include return types in JSDoc
...
Add types to @returns JSDoc annotations where the type is missing.
PR-URL: https://github.com/nodejs/node/pull/41130
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2021-12-12 03:51:00 +00:00
James M Snell
af28b0d540
stream: use cause options in AbortError constructors
...
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/41008
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2021-12-02 12:14:10 -08:00
Robert Nagy
3f0b62375b
stream: convert premature close to AbortError
...
AbortError is a more "web" align alternative to
ERR_STREAM_PREMATURE_CLOSE.
PR-URL: https://github.com/nodejs/node/pull/39524
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-07-28 10:12:04 +02:00
Rich Trott
44ee6c2623
stream: call done() in consistent fashion
...
All three `destroy()` functions defined in adapter.js contain a `done()`
function that takes no arguments. In one instance, however, an argument
is nonetheless passed. Remove it for consistency.
PR-URL: https://github.com/nodejs/node/pull/39475
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Evan Lucas <evanlucas@me.com >
2021-07-22 23:50:13 +00:00
James M Snell
6cd12be347
fs: add FileHandle.prototype.readableWebStream()
...
Adds an experimental `readableWebStream()` method to `FileHandle` that
returns a web `ReadableStream`
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/39331
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2021-07-15 13:43:20 -07:00
James M Snell
a99c230305
stream: implement streams to webstreams adapters
...
Experimental adapters for the webstreams API
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/39134
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2021-07-13 10:03:16 -07:00