lib: refactor unhandled rejection deprecation warning emission#28258
lib: refactor unhandled rejection deprecation warning emission#28258joyeecheung wants to merge 2 commits intonodejs:masterfrom
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.
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.
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>
BridgeAR
left a comment
There was a problem hiding this comment.
Seems like I forgot to submit my review.
| if (!deprecationWarned) { | ||
| emitDeprecationWarning(); | ||
| deprecationWarned = true; | ||
| } |
There was a problem hiding this comment.
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
kDefaultUnhandledRejectionscase 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