Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

@joyeecheung
Copy link
Member

commented Jun 17, 2019

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()

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
@nodejs-github-bot

This comment has been minimized.

Copy link

commented Jun 17, 2019

Sadly, an error occurred when I tried to trigger a build. :(

lib: refactor unhandled rejection deprecation warning emission
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()`

@joyeecheung joyeecheung force-pushed the joyeecheung:rejection-switch branch from 750b7f3 to 206c735 Jun 17, 2019

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@joyeecheung

This comment has been minimized.

Copy link
Member Author

commented Jun 18, 2019

}

let deprecationWarned = false;
function emitDeprecationWarning() {
if (unhandledRejectionsMode === kDefaultUnhandledRejections &&

This comment has been minimized.

Copy link
@benjamingr

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.

Copy link
@joyeecheung

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 benjamingr requested a review from BridgeAR Jun 18, 2019

@joyeecheung

This comment has been minimized.

Copy link
Member Author

commented Jun 19, 2019

Landed in 1c23b6f

joyeecheung added a commit that referenced this pull request Jun 19, 2019
lib: refactor unhandled rejection deprecation warning emission
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>
targos added a commit that referenced this pull request Jul 2, 2019
lib: refactor unhandled rejection deprecation warning emission
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>
@targos targos referenced this pull request Jul 2, 2019
@BridgeAR
Copy link
Member

left a comment

Seems like I forgot to submit my review.

if (!deprecationWarned) {
emitDeprecationWarning();
deprecationWarned = true;
}

This comment has been minimized.

Copy link
@BridgeAR

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.