-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
lib: refactor unhandled rejection deprecation warning emission #28258
Conversation
Sadly, an error occurred when I tried to trigger a build. :( |
Emit the deprecation warning in the `kDefaultUnhandledRejections` case to reduce the number of branches on unhandled rejection mode - there is now only one switch case on it. Also rename `emitWarning()` to `emitUnhandledRejectionWarning()` to avoid ambiguity with `process.emitWarning()`
750b7f3
to
206c735
Compare
cc @nodejs/process |
} | ||
|
||
let deprecationWarned = false; | ||
function emitDeprecationWarning() { | ||
if (unhandledRejectionsMode === kDefaultUnhandledRejections && |
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.
Won't this emit the warning every time rather than just once?
Also - doesn't this break the flag?
cc @BridgeAR
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.
The only call site of emitDeprecationWarning()
is now L200 which is already guarded with deprecationWarned
.
Also the only branch on unhandledRejectionsMode
is on L180 so you can see what actions are done for each mode by simply looking at that switch instead of jumping in multiple nested functions.
Landed in 1c23b6f |
Emit the deprecation warning in the `kDefaultUnhandledRejections` case to reduce the number of branches on unhandled rejection mode - there is now only one switch case on it. Also rename `emitWarning()` to `emitUnhandledRejectionWarning()` to avoid ambiguity with `process.emitWarning()` PR-URL: #28258 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Emit the deprecation warning in the `kDefaultUnhandledRejections` case to reduce the number of branches on unhandled rejection mode - there is now only one switch case on it. Also rename `emitWarning()` to `emitUnhandledRejectionWarning()` to avoid ambiguity with `process.emitWarning()` PR-URL: #28258 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
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.
Seems like I forgot to submit my review.
if (!deprecationWarned) { | ||
emitDeprecationWarning(); | ||
deprecationWarned = true; | ||
} |
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.
The second if should be part of the first one. Otherwise the deprecation notice will be visible even though the user handled the rejection.
Emit the deprecation warning in the
kDefaultUnhandledRejections
case to reduce the number of branches on unhandled rejection mode -
there is now only one switch case on it.
Also rename
emitWarning()
toemitUnhandledRejectionWarning()
to avoid ambiguity with
process.emitWarning()
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes