-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stream: support passing generator functions into pipeline #31223
Conversation
92c9e6f
to
db3aaa3
Compare
I would prefer we did not pass through the stream equivalents for pipeline - I'm not sure if it's feasible. The main reason is performance: streams adds a lot of overhead and a pipeline composed by async iterators can be extremely more performant. I'm not sure if this is feasible or just a dream. |
Might be feasible. I've updated the PR. |
d7035ec
to
227642e
Compare
@mcollina: I think you will like this iteration. Now it's possible to do e.g. let res = '';
pipeline(async function*() {
await new Promise((resolve) => process.nextTick(resolve));
yield 'hello';
yield 'world';
}, async function*(source) {
for await (const chunk of source) {
yield chunk.toUpperCase();
}
}, async function(source) {
for await (const chunk of source) {
res += chunk;
}
}, common.mustCall((err) => {
assert.strictEqual(err, undefined);
assert.strictEqual(res, 'HELLOWORLD');
})); Without passing through the stream equivalents for pipeline. Still needs some work to ensure edge cases are covered and errors are properly thrown. WIP label please. |
227642e
to
d26e808
Compare
Backport-PR-URL: nodejs#31975 PR-URL: nodejs#31223 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Backport-PR-URL: #31975 PR-URL: #31223 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Notable changes: * async_hooks * introduce async-context API (vdeturckheim) #26540 * stream * support passing generator functions into pipeline() (Robert Nagy) #31223 * tls * expose SSL\_export\_keying\_material (simon) #31814 * vm * implement vm.measureMemory() for per-context memory measurement (Joyee Cheung) #31824 PR-URL: #32027
Notable changes: * async_hooks * introduce async-context API (vdeturckheim) #26540 * stream * support passing generator functions into pipeline() (Robert Nagy) #31223 * tls * expose SSL\_export\_keying\_material (simon) #31814 * vm * implement vm.measureMemory() for per-context memory measurement (Joyee Cheung) #31824 PR-URL: #32027
Notable changes: * async_hooks * introduce async-context API (vdeturckheim) #26540 * stream * support passing generator functions into pipeline() (Robert Nagy) #31223 * tls * expose SSL\_export\_keying\_material (simon) #31814 * vm * implement vm.measureMemory() for per-context memory measurement (Joyee Cheung) #31824 PR-URL: #32027
Notable changes: * async_hooks * introduce async-context API (vdeturckheim) #26540 * stream * support passing generator functions into pipeline() (Robert Nagy) #31223 * tls * expose SSL\_export\_keying\_material (simon) #31814 * vm * implement vm.measureMemory() for per-context memory measurement (Joyee Cheung) #31824 PR-URL: #32027
Notable changes: * async_hooks * introduce async-context API (vdeturckheim) #26540 * stream * support passing generator functions into pipeline() (Robert Nagy) #31223 * tls * expose SSL\_export\_keying\_material (simon) #31814 * vm * implement vm.measureMemory() for per-context memory measurement (Joyee Cheung) #31824 PR-URL: #32027
@ronag does this still need a backport? |
@MylesBorins I've already backported it #31975. Did I miss a label or something? |
@ronag thanks! when something has been backported we usually apply a different label. |
Depends at least on #30869 to land on v12.x |
@targos: I don't think this should land on v12 |
@ronag why not? I we do not backport the recent stream changes, this subsystem will be really difficult to maintain on v12. There are almost conflicts with every pull request. |
Disregard my previous comment. You are right. |
Add support for generators and functions in
pipeline
.This makes it possible to do the following:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes