-
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
Allow multiple readers to iterate over a stream at the same time #52086
Comments
Hi @ehmicky, I had a look at your implementation and realised you took the effort to make it work with both node |
Hi @jakecastelli, The implementation in
Overall, IMHO, it would be safer to keep the current Node.js implementation, and provide this new behavior as an opt-in, for backward compatibility. For example, using a boolean option to As a side note, please note that the implementation in However, since |
My team is claiming this issue. |
@nodejs/streams should |
@mycoleb your what is what? |
Maybe? It's just tricky to get semantics right namely backpressure/watermarking and cleanup/resources. A tee'd stream should get destroyed when all its forks get destroyed, it should communicate backpressure etc - and we need to decide what happens when one "fork" is flowing and one is not |
I didn't say it is simple, but this is a very common need |
Yeah my point is we shouldn't land an implementation that doesn't deal with these things |
Unfortunately, using A proper implementation of this is exceptionally hard. I'm not opposed to add |
What is the problem this feature will solve?
When multiple callers use
Readable[Symbol.asyncIterator]
, each caller receives a partial result.Some callers might expect that result. But others might expect the following result instead.
What is the feature you are proposing to solve the problem?
Adding an option to
readable.iterator()
to usereadable.on('data')
instead ofreadable.read()
. This would enable the above behavior.What alternatives have you considered?
Implementing this user-land.
See an example of it at sindresorhus/get-stream#121
The text was updated successfully, but these errors were encountered: