node
node copied to clipboard
webstreams: integrate into common stream utils
With the introduction of web streams, it would be good to integrate support into the various common stream utilities...
Refs: https://github.com/nodejs/node/pull/39134
/cc @mcollina @ronag
-
stream.finished()
const { finished } = require('stream');
finished(new ReadableStream(), (err) => { /* ... */ });
finished(new WritableStream(), (err) => { /* ... */ });
finished(new TransformStream(), (err) => { /* ... */ });
import { finished } from 'stream/promises';
await finished(new ReadableStream());
await finished(new WritableStream());
await finished(new TransformStream());
-
stream.pipeline()
const { pipeline } = require('stream');
pipeline(new ReadableStream(), new TransformStream(), new WritableStream(), (err) => { /* ... */ });
import { pipeline } from 'stream/promises';
await pipeline(new ReadableStream(), new TransformStream(), new WritableStream());
-
stream.addAbortSignal()
const { addAbortSignal } = require('stream');
const ac = new AbortController();
const readable = new ReadableStream();
addAbortSignal(ac.signal, readable);
-
stream.compose()
(https://github.com/nodejs/node/pull/39029)
As far as streams goes, this is probably a good first issue.
Going to take a look at this as my first issue. Is that okay?
No need to ask for permission. Just go ahead.
Hello, I would like to assist on this issue. Can I get some more documentation and reading
import { pipeline } from 'stream/promises';
await pipeline(new ReadableStream(), new TransformStream(), new WritableStream());
Adapting pipeline to whatwg:streams feels almost a bit unnecessary, whatwg:streams are already kind of promise based already
await new ReadableStream()
.pipeThrough(new TransformStream())
.pipeTo(new WritableStream())
I think i would never use pipeline and whatwg:streams together, I don't know so much about finished
either...
https://github.com/nodejs/node/pull/39519 did add support for some of the things here but lacked tests so it was disabled. If someone wants to pick up this issue I would recommend looking at https://github.com/nodejs/node/pull/39519, uncomment the web stream stuff, add tests and fix any remaining issue there.
Thanks for the heads up. I'll take a look this week :)
Adapting pipeline to whatwg:streams feels almost a bit unnecessary, whatwg:streams are already kind of promise based already
The goal should be to add those for cross compatibility, so we can "pipe" from a WHATWG Stream to a Node.js Stream easily and without additional overhead.
@mcollina does this still need to be handled? I can take it if so, although will take me a while.
is this issue still unresolved ?? Can anyone tell me please??
I think this is still unresolved. A PR adding support (or at a minimum tests) for this would be highly appreciated.
The use case these utilities are there to answer is to create interoperability between webstreams and nodestreams.
@mcollina any documentation I can read to get more information on this? I feel like I can handle this as a first-timer.
Not much TBH, however in the simplistic form: start writing a test, and keep working until it passes.
#39519 did add support for some of the things here but lacked tests so it was disabled. If someone wants to pick up this issue I would recommend looking at #39519, uncomment the web stream stuff, add tests and fix any remaining issue there.
@mcollina maybe pick up after this?
yes!
Can i take up this issue or it is resolved?
go for it
Implemented in:
-
finished()
https://github.com/nodejs/node/commit/32254988ba7c0c0a68d8dfbc32430466370bf170 -
pipeline()
https://github.com/nodejs/node/commit/23effb255efe3eb0dc935e3a430d80b41ea1e660 -
addAbortSignal()
https://github.com/nodejs/node/commit/96c720e98f4ea80103a9d240ae8072190a226729 -
compose()
https://github.com/nodejs/node/commit/94e1f8f8e139680d1de0531d8aaf7f971cfaa953