stream: don't emit errors after destroy#29211
Closed
ronag wants to merge 1 commit intonodejs:masterfrom
Closed
Conversation
Member
Author
- Don't emit any error on destroy(). - Emit error on destroy(err). - Always pass any error to callbak in destroy(err, cb).
91ffb11 to
e056535
Compare
Member
I don't think this is a good idea. See #29197 (comment) |
4 tasks
Member
Author
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This one is probably going to be a bit controversial but please give it a chance. It's the continuation on some related but less controversial PR's (e.g. #29197)
Basically it tries to enforce the following rules:
destroy(err).destroy()(including ifdestroy(err)is called afterwards).destroy(err, cb)ordestroy(null, cb).The idea is to try to avoid unexpectedly crashing the user's application or emit any unexpected errors (even if the user has error listeners registered). Most users (I believe?) assume that after
destroy()no more errors will be emitted, i.e. the object is practically "killed".In the case where an error is explicitly passed to
destroy(err), it still makes sense to emit one error. Since the user has explicitly passed one.If the user wants to handle any errors on the no error case they should pass a callback in
destroy(null, cb). This would also probably require that the undocumented/internal callback API fordestroy()is documented.This is semver-major but I don't believe the chances of it breaking anything are very high.
The tests also need a little more polish (I'll do that if there is interest in going forward with this PR).
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes