-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Inconsistent stream events using destroy method #25373
Comments
cc @nodejs/streams |
This sentence is in the docs:
needs to be updated as all streams will emit
That is not true, as the docs report:
It does not mention anything related to the error conditions. I'm not 100% sure why |
Thank you for the response. Just for info, I've noticed the same behavior with Readable streams. I've also found a workaround, a setImmediate (nextTick does not work) on end, finish and close event callbacks does the trick. |
See: nodejs#25373 See: nodejs#18438 PR-URL: nodejs#25413 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
As for official Node.js docs, with a custom Writable, the only standard way to know if the stream has finished, is to listen the finish event.
The code above works correctly on both node 8 and 10, with the finish event emitted.
The problem I've noticed is during the usage of the destroy() method, on node 8 the stream will emit first the finish event, then a error event, and no close event.
On node 10, the finish event is not emitted.
I'm not sure if the problem is node 8 or 10, but by reading the docs I suppose the finish event have to be emitted after a possible error.
The text was updated successfully, but these errors were encountered: