-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: clarify stream errors while reading and writing
Errors should be propagated through destroy(err). Anything else is basically undefined behaviour. PR-URL: #29653 Refs: #29584 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
Showing
1 changed file
with
18 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7223ce2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ronag @Trott the docs here are a bit confusing. For readable stream, it says "Errors occurring during processing of the readable._read() must be propagated through the readable.destroy(err) method. Throwing an Error from within readable._read() or manually emitting an 'error' event results in undefined behavior."
This does not seem right because if we call destroy(err) directly, this bypasses any
autoDestroy
flag set in the stream. In fact, many of the examples in the wild seems to emit('error', e) inside_read
. Is all that code incorrect or are the docs wrong? If the docs are correct, what is the correct way to signal errors for readable streams withautoDestroy
set to false?7223ce2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should always call destroy even if autoDestroy false.