-
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
stream: avoid unhandled exception when destroy w/ callback. #30970
Conversation
49f20a0
to
badc716
Compare
@@ -52,6 +54,11 @@ function destroy(err, cb) { | |||
r.destroyed = true; | |||
} | |||
|
|||
if (cb) { |
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.
Perhaps here and elsewhere in this function we should instead check typeof cb === 'function'
?
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.
We don't do that anywhere else in this file. If you'd prefer it like that, I would prefer to handle that in a separate PR and change it everywhere in this file.
@lpinca: Are you ok with this change? The error is not swallowed per se. |
Is there a particular reason? Adding |
@nodejs/streams |
For me this is about the unhandled exception behavior
We emit an unhandled exception error and close the program because the exception is supposedly unhandled. If the user provides a callback and do handle it, this behavior is in my opinion both unintuitive and unnecessary.
I think that might be worth into looking into / consider updating those and others as well. I was hoping to propose that in a separate semver major PR if there is consensus on this one. |
Providing a callback to destroy means that the error should be handled through that callback and thus an unhandled exception error should not be necessary.
1755b8c
to
248c405
Compare
For context I'm just probing a bit in regards to how much of normalized destroy would make sense to move into core streams and how much makes sense to be an outside util. |
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.
We are using that callback internally at least once. Can you please verify where we are using it right now and if this would break them?
I think this is semver-major.
Docs are missing.
Given the limited use we could also fix so that the
This is not a public API (yet). |
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.
This needs a rebase.
Blocked by #29179 |
Been some related progress on other PR's. Closing this for now and re-opening later. |
Providing a callback to destroy means that the error should be handled through that callback and thus an unhandled exception error should not be necessary.
Some minor preparation towards possibly making the
destroy(err, cb)
signature public.With "better" ergonomics I'm hoping users that usually skip adding an
'error'
listeners beforedestroy()
no longer end up with unhandled exceptions in edge cases.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes