You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.
The 'data' event is emitted whenever the stream is relinquishing ownership of a chunk of data to a consumer. This may occur whenever the stream is switched in flowing mode by calling readable.pipe(), readable.resume(), or by attaching a listener callback to the 'data' event.
The 'end' event is emitted when there is no more data to be consumed from the stream. The 'end' event will not be emitted unless the data is completely consumed. This can be accomplished by switching the stream into flowing mode, or by calling stream.read() repeatedly until all data has been consumed.
I think it follows that, if there is data available on a non-flowing readable stream, then registering the data handler will cause it to start flowing and potentially result in the 'end' event firing immediately.
The text was updated successfully, but these errors were encountered:
BryceCicada
changed the title
Should register 'end' event listener before 'data' listener.
Callback not called / promise not resolved for non-flowing streams with data.
Apr 27, 2018
@BryceCicada it seems like the module is not emitting the data chunks after the initial event loop, which is incorrect. however, this module is no longer necessary so we won't fix this. thank you for the report!
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Thanks for this library. I've found the following issue after using stream-to-promise that depends on this library.
Consider the following code that has a paused readable stream containing data at the time of calling
toArray()
:The promise never resolves.
On digging, it appears that, within stream-to-array, event listeners are registered in the following order:
However, if I change the order of listener registration ('end' before 'data') then the promise will resolve.
From the docs for Streams at https://nodejs.org/api/stream.html:
I think it follows that, if there is data available on a non-flowing readable stream, then registering the data handler will cause it to start flowing and potentially result in the 'end' event firing immediately.
The text was updated successfully, but these errors were encountered: