Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign uplib: refactor unhandled rejection deprecation warning emission #28258
Conversation
This comment has been minimized.
This comment has been minimized.
nodejs-github-bot
commented
Jun 17, 2019
|
Sadly, an error occurred when I tried to trigger a build. :( |
nodejs-github-bot
added
the
process
label
Jun 17, 2019
joyeecheung
force-pushed the
joyeecheung:rejection-switch
branch
from
750b7f3
to
206c735
Jun 17, 2019
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| let deprecationWarned = false; | ||
| function emitDeprecationWarning() { | ||
| if (unhandledRejectionsMode === kDefaultUnhandledRejections && |
This comment has been minimized.
This comment has been minimized.
benjamingr
Jun 18, 2019
Member
Won't this emit the warning every time rather than just once?
Also - doesn't this break the flag?
cc @BridgeAR
This comment has been minimized.
This comment has been minimized.
joyeecheung
Jun 18, 2019
•
Author
Member
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.
benjamingr
requested a review
from BridgeAR
Jun 18, 2019
This comment has been minimized.
This comment has been minimized.
|
Landed in 1c23b6f |
joyeecheung
closed this
Jun 19, 2019
|
Seems like I forgot to submit my review. |
| if (!deprecationWarned) { | ||
| emitDeprecationWarning(); | ||
| deprecationWarned = true; | ||
| } |
This comment has been minimized.
This comment has been minimized.
BridgeAR
Jul 4, 2019
Member
The second if should be part of the first one. Otherwise the deprecation notice will be visible even though the user handled the rejection.
joyeecheung commentedJun 17, 2019
•
edited
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