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

test: make crashOnUnhandleRejection opt-out #21849

Closed

Conversation

targos
Copy link
Member

@targos targos commented Jul 17, 2018

This commit removes common.crashOnUnhandledRejection() and adds
common.disableCrashOnUnhandledRejection().

To reduce the risk of mistakes and make writing tests that involve
promises simpler, always install the unhandledRejection hook in tests
and provide a way to disable it for there rare cases where it's needed.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@targos targos added test Issues and PRs related to the tests. promises Issues and PRs related to ECMAScript promises. labels Jul 17, 2018
@targos
Copy link
Member Author

targos commented Jul 17, 2018

@targos targos added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 17, 2018
@@ -55,12 +55,13 @@ symlinks
([SeCreateSymbolicLinkPrivilege](https://msdn.microsoft.com/en-us/library/windows/desktop/bb530716(v=vs.85).aspx)).
On non-Windows platforms, this always returns `true`.

### crashOnUnhandledRejection()
### disableCrashOnUnhandledRejection()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be placed after the ddCommand() now)

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

targos added 2 commits July 19, 2018 08:38
This commit removes `common.crashOnUnhandledRejection()` and adds
`common.disableCrashOnUnhandledRejection()`.

To reduce the risk of mistakes and make writing tests that involve
promises simpler, always install the unhandledRejection hook in tests
and provide a way to disable it for there rare cases where it's needed.
@targos targos force-pushed the test-always-crash-unhandled-rejection branch from 49d1b4b to a94af81 Compare July 19, 2018 06:39
@targos
Copy link
Member Author

targos commented Jul 19, 2018

Landed in df08779

@targos targos closed this Jul 19, 2018
@targos targos deleted the test-always-crash-unhandled-rejection branch July 19, 2018 06:48
targos added a commit that referenced this pull request Jul 19, 2018
This commit removes `common.crashOnUnhandledRejection()` and adds
`common.disableCrashOnUnhandledRejection()`.

To reduce the risk of mistakes and make writing tests that involve
promises simpler, always install the unhandledRejection hook in tests
and provide a way to disable it for the rare cases where it's needed.

PR-URL: #21849
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@targos targos removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 19, 2018
@targos
Copy link
Member Author

targos commented Jul 19, 2018

Depends on #20830 to land on v10.x-staging

process.on('unhandledRejection',
(err) => process.nextTick(() => { throw err; }));
const crashOnUnhandledRejection = (err) => { throw err; };
process.on('unhandledRejection', crashOnUnhandledRejection);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it intentional to drop the process.nextTick()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not. Do you think we should put it back?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure -- I was confused because the README says:

Removes the process.on('unhandledRejection') handler that crashes the process
after a tick.

so I assumed the process.nextTick() in the original code was intentional. ¯\_(ツ)_/¯

Copy link
Member Author

@targos targos Jul 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @addaleax since you implemented it initially. Was there a reason to throw in the next tick? I can't see any difference on a local test with or without process.nextTick.

Edit: commit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@targos I don’t remember – I’d assume dropping it is okay.

targos added a commit that referenced this pull request Jul 24, 2018
This commit removes `common.crashOnUnhandledRejection()` and adds
`common.disableCrashOnUnhandledRejection()`.

To reduce the risk of mistakes and make writing tests that involve
promises simpler, always install the unhandledRejection hook in tests
and provide a way to disable it for the rare cases where it's needed.

PR-URL: #21849
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@targos targos mentioned this pull request Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
promises Issues and PRs related to ECMAScript promises. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.