Skip to content
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

quick fix for already-ended streams #29

Closed
wants to merge 2 commits into from

Conversation

xloem
Copy link

@xloem xloem commented Apr 1, 2020

This is a naive attempt for something that fixes #28

@xloem
Copy link
Author

xloem commented Apr 1, 2020

Travis e-mailed me. I see you're intending to support down to nodejs 4. This fix only passed my test on nodejs 8 and above. I don't know how to detect whether a stream has ended on nodejs 4.

@mafintosh
Copy link
Owner

Streams can be many versions due to readable-stream existing so we support a vast majority of them. This a non trivial problem.

What's your real life use-case for this?

@xloem
Copy link
Author

xloem commented Apr 1, 2020

I'm trying to robustly pull the next item from a stream and throw an error if there is none. https://npmjs.com/package/stream-shift-promise (as part of a library and tool that uses streams a lot).

I'm not personally worried about versions of npm no longer generally distributed, but I was kind of hoping if I could find another project to merge the idea into it might get better maintenance down the road, with more users.

EDIT: It sounds like for this idea to be merged, you'd need me to review all the forms of streams that use this library and make it work for them? Do you know if this is possible for them all?

@xloem
Copy link
Author

xloem commented Apr 1, 2020

I'm trying to make a tool for probing forms of blockchain data. It seemed it would be nice to use streams under the hood, since the size range of stuff can vary from miniscule to humongous. I was running into a lot of issues connecting streams together so I started working on libraries. EDIT: If I offer everything as a stream, the function is useful for retrieving only the first item if it is the only one of interest. I then hope to get backflow propagating back up so no more data need be generated. But if the request is bad the stream will be empty before it is shifted from.

@mafintosh
Copy link
Owner

Yea this module got massive usage in the ecosystem so we gonna have to test a wide variety of streams to not break stuff. I think any change made to here in the last 12-24 months has caused breakage hehe.

The reason I'm asking about a use case is that I don't think I've had the need to listen for stream end some time after making the stream instance. You gotta error handle it right away anyway. I normally check using stream.destroyed if a stream has error if I need to check that.

@xloem
Copy link
Author

xloem commented Apr 1, 2020

I don't quite understand you. I am trying to use streams to hold all of one value, huge values, and no values, so setting up error handlers would be encapsulated inside something. It sounds like this is not the place, or maybe streams not the tool. Thank you.

@xloem xloem closed this Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Call callback immediately if stream is already closed.
2 participants