-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
test: make crashOnUnhandleRejection opt-out #21849
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
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.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -814,9 +814,10 @@ exports.getBufferSources = function getBufferSources(buf) { | |
| }; | ||
|
|
||
| // Crash the process on unhandled rejections. | ||
| exports.crashOnUnhandledRejection = function() { | ||
| process.on('unhandledRejection', | ||
| (err) => process.nextTick(() => { throw err; })); | ||
| const crashOnUnhandledRejection = (err) => { throw err; }; | ||
| process.on('unhandledRejection', crashOnUnhandledRejection); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was it intentional to drop the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was not. Do you think we should put it back?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure -- I was confused because the README says:
so I assumed the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @targos I don’t remember – I’d assume dropping it is okay. |
||
| exports.disableCrashOnUnhandledRejection = function() { | ||
| process.removeListener('unhandledRejection', crashOnUnhandledRejection); | ||
| }; | ||
|
|
||
| exports.getTTYfd = function getTTYfd() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| // Flags: --trace-warnings | ||
| 'use strict'; | ||
| require('../common'); | ||
| const common = require('../common'); | ||
| common.disableCrashOnUnhandledRejection(); | ||
| const p = Promise.reject(new Error('This was rejected')); | ||
| setImmediate(() => p.catch(() => {})); |
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.
Should be placed after the
ddCommand()now)