| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3377eb9 commit 05df701
17 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -250,11 +250,9 @@ countdown.dec(); // The countdown callback will be invoked now. | |||
| 250 | 250 | ||
| 251 | 251 | When writing tests involving promises, it is generally good to wrap the | |
| 252 | 252 | `onFulfilled` handler, otherwise the test could successfully finish if the | |
| 253 | - promise never resolves (pending promises do not keep the event loop alive). The | ||
| 254 | - `common` module automatically adds a handler that makes the process crash - and | ||
| 255 | - hence, the test fail - in the case of an `unhandledRejection` event. It is | ||
| 256 | - possible to disable it with `common.disableCrashOnUnhandledRejection()` if | ||
| 257 | - needed. | ||
| 253 | + promise never resolves (pending promises do not keep the event loop alive). | ||
| 254 | + Node.js automatically crashes - and hence, the test fails - in the case of an | ||
| 255 | + `unhandledRejection` event. | ||
| 258 | 256 | ||
| 259 | 257 | ```js | |
| 260 | 258 | const common = require('../common'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,14 +61,6 @@ On non-Windows platforms, this always returns `true`. | |||
| 61 | 61 | ||
| 62 | 62 | Creates a 10 MB file of all null characters. | |
| 63 | 63 | ||
| 64 | - ### `disableCrashOnUnhandledRejection()` | ||
| 65 | - | ||
| 66 | - Removes the `process.on('unhandledRejection')` handler that crashes the process | ||
| 67 | - after a tick. The handler is useful for tests that use Promises and need to make | ||
| 68 | - sure no unexpected rejections occur, because currently they result in silent | ||
| 69 | - failures. However, it is useful in some rare cases to disable it, for example if | ||
| 70 | - the `unhandledRejection` hook is directly used by the test. | ||
| 71 | - | ||
| 72 | 64 | ### `enoughTestCpu` | |
| 73 | 65 | ||
| 74 | 66 | * [<boolean>][] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -628,10 +628,6 @@ function getBufferSources(buf) { | |||
| 628 | 628 | return [...getArrayBufferViews(buf), new Uint8Array(buf).buffer]; | |
| 629 | 629 | } | |
| 630 | 630 | ||
| 631 | - function disableCrashOnUnhandledRejection() { | ||
| 632 | - process.on('unhandledRejection', () => {}); | ||
| 633 | - } | ||
| 634 | - | ||
| 635 | 631 | function getTTYfd() { | |
| 636 | 632 | // Do our best to grab a tty fd. | |
| 637 | 633 | const tty = require('tty'); | |
@@ -732,7 +728,6 @@ const common = { | |||
| 732 | 728 | canCreateSymLink, | |
| 733 | 729 | childShouldThrowAndAbort, | |
| 734 | 730 | createZeroFilledFile, | |
| 735 | - disableCrashOnUnhandledRejection, | ||
| 736 | 731 | expectsError, | |
| 737 | 732 | expectWarning, | |
| 738 | 733 | gcUntil, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,7 +46,6 @@ const { | |||
| 46 | 46 | skipIf32Bits, | |
| 47 | 47 | getArrayBufferViews, | |
| 48 | 48 | getBufferSources, | |
| 49 | - disableCrashOnUnhandledRejection, | ||
| 50 | 49 | getTTYfd, | |
| 51 | 50 | runWithInvalidFD | |
| 52 | 51 | } = common; | |
@@ -92,7 +91,6 @@ export { | |||
| 92 | 91 | skipIf32Bits, | |
| 93 | 92 | getArrayBufferViews, | |
| 94 | 93 | getBufferSources, | |
| 95 | - disableCrashOnUnhandledRejection, | ||
| 96 | 94 | getTTYfd, | |
| 97 | 95 | runWithInvalidFD, | |
| 98 | 96 | createRequire | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,6 @@ function spawnChildProcess(inspectorFlags, scriptContents, scriptFile) { | |||
| 25 | 25 | const handler = tearDown.bind(null, child); | |
| 26 | 26 | process.on('exit', handler); | |
| 27 | 27 | process.on('uncaughtException', handler); | |
| 28 | - common.disableCrashOnUnhandledRejection(); | ||
| 29 | 28 | process.on('unhandledRejection', handler); | |
| 30 | 29 | process.on('SIGINT', handler); | |
| 31 | 30 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,8 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | - const common = require('../common'); | ||
| 3 | + require('../common'); | ||
| 4 | 4 | ||
| 5 | 5 | if (process.argv[2] === 'async') { | |
| 6 | - common.disableCrashOnUnhandledRejection(); | ||
| 7 | 6 | async function fn() { | |
| 8 | 7 | fn(); | |
| 9 | 8 | throw new Error(); | |
@@ -16,7 +15,7 @@ const { spawnSync } = require('child_process'); | |||
| 16 | 15 | ||
| 17 | 16 | const ret = spawnSync( | |
| 18 | 17 | process.execPath, | |
| 19 | - ['--stack_size=150', __filename, 'async'], | ||
| 18 | + ['--unhandled-rejections=none', '--stack_size=150', __filename, 'async'], | ||
| 20 | 19 | { maxBuffer: Infinity } | |
| 21 | 20 | ); | |
| 22 | 21 | assert.strictEqual(ret.status, 0, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,10 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | import { | |
| 4 | 4 | mustCall, | |
| 5 | - disableCrashOnUnhandledRejection | ||
| 6 | 5 | } from '../common/index.mjs'; | |
| 7 | 6 | ||
| 8 | - disableCrashOnUnhandledRejection(); | ||
| 9 | - | ||
| 10 | 7 | process.on('unhandledRejection', mustCall()); | |
| 11 | 8 | Promise.reject(new Error('should not be fatal error')); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,6 @@ | |||
| 2 | 2 | const common = require('../common'); | |
| 3 | 3 | ||
| 4 | 4 | // This test verifies that DEP0018 does not occur when rejections are handled. | |
| 5 | - common.disableCrashOnUnhandledRejection(); | ||
| 6 | 5 | process.on('warning', common.mustNotCall()); | |
| 7 | 6 | process.on('unhandledRejection', common.mustCall()); | |
| 8 | 7 | Promise.reject(new Error()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,8 +5,6 @@ const common = require('../common'); | |||
| 5 | 5 | const Countdown = require('../common/countdown'); | |
| 6 | 6 | const assert = require('assert'); | |
| 7 | 7 | ||
| 8 | - common.disableCrashOnUnhandledRejection(); | ||
| 9 | - | ||
| 10 | 8 | // Verify that unhandled rejections always trigger uncaught exceptions instead | |
| 11 | 9 | // of triggering unhandled rejections. | |
| 12 | 10 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,8 +4,6 @@ | |||
| 4 | 4 | const common = require('../common'); | |
| 5 | 5 | const assert = require('assert'); | |
| 6 | 6 | ||
| 7 | - common.disableCrashOnUnhandledRejection(); | ||
| 8 | - | ||
| 9 | 7 | // Verify that ignoring unhandled rejection works fine and that no warning is | |
| 10 | 8 | // logged even though there is no unhandledRejection hook attached. | |
| 11 | 9 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments