-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Avoid PassThrough to avoid buffering in pipeline #32039
Comments
cc @ronag |
This is only when the last argument in pipeline is not a stream, thus we must create a stream since I don't think this is a big issue. If we want to fix it we need to change the return signature of |
i.e. it's to make the following valid: pipeline(src, function*(source) {
for await (const chunk of source) {
yield chunk
}
}, err => { }).pipe(dst); Notice the |
I think the current code is correct then, maybe we should add some comments to |
I'll prepare a PR this week. |
@mcollina: there is however one case I would like to optimize, consider: const src = Readable.from(asyncGenerator())
pipeline(src, dst, err => {}) In this case I think pipeline should be able to unwrap the original generator, which would however require In the future I would like encourage users to implement readable, transform and writable in terms of generators and wrap only for compatibility. |
In the new async-terator capable pipeline as implemented in #31223, we support passing in an async generator function.
Reading from
node/lib/internal/streams/pipeline.js
Line 191 in 6bcea0a
We should avoid wrapping it in a
PassThrough
to avoid said buffering and overhead.The text was updated successfully, but these errors were encountered: