summaryrefslogtreecommitdiff
path: root/test/parallel
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2018-07-17 08:23:49 +0200
committerMichaël Zasso <targos@protonmail.com>2018-07-19 08:47:28 +0200
commitdf08779e0dfa82ceb69e129ae0548e97352aaddf (patch)
treea589930afbeaf5481f3fe614eeee05fc04b7ec35 /test/parallel
parent373aae1f86c1d061123e3aec28980aa2e7d1ebd4 (diff)
downloadnode-new-df08779e0dfa82ceb69e129ae0548e97352aaddf.tar.gz
test: make crashOnUnhandleRejection opt-out
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: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'test/parallel')
-rw-r--r--test/parallel/test-assert-async.js2
-rw-r--r--test/parallel/test-async-hooks-disable-during-promise.js1
-rw-r--r--test/parallel/test-async-hooks-enable-during-promise.js2
-rw-r--r--test/parallel/test-async-hooks-promise-enable-disable.js2
-rw-r--r--test/parallel/test-async-hooks-promise-triggerid.js2
-rw-r--r--test/parallel/test-async-wrap-pop-id-during-load.js3
-rw-r--r--test/parallel/test-async-wrap-promise-after-enabled.js2
-rw-r--r--test/parallel/test-c-ares.js2
-rw-r--r--test/parallel/test-child-process-promisified.js2
-rw-r--r--test/parallel/test-dns-lookup.js2
-rw-r--r--test/parallel/test-dns-promises-resolve.js2
-rw-r--r--test/parallel/test-dns-resolveany-bad-ancount.js2
-rw-r--r--test/parallel/test-dns-resolveany.js2
-rw-r--r--test/parallel/test-dns-resolvens-typeerror.js2
-rw-r--r--test/parallel/test-dns.js2
-rw-r--r--test/parallel/test-domain-promise.js2
-rw-r--r--test/parallel/test-fs-lchown.js2
-rw-r--r--test/parallel/test-fs-promises-file-handle-append-file.js1
-rw-r--r--test/parallel/test-fs-promises-file-handle-chmod.js1
-rw-r--r--test/parallel/test-fs-promises-file-handle-read.js1
-rw-r--r--test/parallel/test-fs-promises-file-handle-readFile.js1
-rw-r--r--test/parallel/test-fs-promises-file-handle-stat.js1
-rw-r--r--test/parallel/test-fs-promises-file-handle-sync.js4
-rw-r--r--test/parallel/test-fs-promises-file-handle-truncate.js1
-rw-r--r--test/parallel/test-fs-promises-file-handle-write.js1
-rw-r--r--test/parallel/test-fs-promises-file-handle-writeFile.js1
-rw-r--r--test/parallel/test-fs-promises-readfile-empty.js4
-rw-r--r--test/parallel/test-fs-promises-readfile.js2
-rw-r--r--test/parallel/test-fs-promises-writefile.js2
-rw-r--r--test/parallel/test-fs-promises.js5
-rw-r--r--test/parallel/test-fs-promisified.js2
-rw-r--r--test/parallel/test-fs-stat-bigint.js1
-rw-r--r--test/parallel/test-http-agent.js1
-rw-r--r--test/parallel/test-http2-backpressure.js2
-rw-r--r--test/parallel/test-http2-client-promisify-connect.js2
-rw-r--r--test/parallel/test-http2-window-size.js1
-rw-r--r--test/parallel/test-inspect-async-hook-setup-at-inspect.js1
-rw-r--r--test/parallel/test-inspector-esm.js2
-rw-r--r--test/parallel/test-inspector-multisession-js.js2
-rw-r--r--test/parallel/test-inspector-multisession-ws.js2
-rw-r--r--test/parallel/test-inspector-reported-host.js2
-rw-r--r--test/parallel/test-inspector-tracing-domain.js2
-rw-r--r--test/parallel/test-internal-module-wrap.js3
-rw-r--r--test/parallel/test-microtask-queue-integration-domain.js4
-rw-r--r--test/parallel/test-microtask-queue-integration.js4
-rw-r--r--test/parallel/test-microtask-queue-run-domain.js4
-rw-r--r--test/parallel/test-microtask-queue-run-immediate-domain.js4
-rw-r--r--test/parallel/test-microtask-queue-run-immediate.js4
-rw-r--r--test/parallel/test-microtask-queue-run.js4
-rw-r--r--test/parallel/test-net-server-max-connections-close-makes-more-available.js8
-rw-r--r--test/parallel/test-promises-unhandled-proxy-rejections.js2
-rw-r--r--test/parallel/test-promises-unhandled-rejections.js4
-rw-r--r--test/parallel/test-promises-unhandled-symbol-rejections.js2
-rw-r--r--test/parallel/test-promises-warning-on-unhandled-rejection.js2
-rw-r--r--test/parallel/test-repl-load-multiline.js2
-rw-r--r--test/parallel/test-repl-top-level-await.js2
-rw-r--r--test/parallel/test-repl.js2
-rw-r--r--test/parallel/test-stream-finished.js2
-rw-r--r--test/parallel/test-stream-pipeline.js2
-rw-r--r--test/parallel/test-stream-readable-async-iterators.js2
-rw-r--r--test/parallel/test-timers-promisified.js2
-rw-r--r--test/parallel/test-util-inspect-namespace.js4
-rw-r--r--test/parallel/test-util-promisify.js2
-rw-r--r--test/parallel/test-util-types.js4
-rw-r--r--test/parallel/test-vm-module-basic.js2
-rw-r--r--test/parallel/test-vm-module-dynamic-import.js1
-rw-r--r--test/parallel/test-vm-module-errors.js1
-rw-r--r--test/parallel/test-vm-module-import-meta.js2
-rw-r--r--test/parallel/test-vm-module-link.js1
-rw-r--r--test/parallel/test-vm-module-reevaluate.js1
-rw-r--r--test/parallel/test-wasm-simple.js4
-rw-r--r--test/parallel/test-zlib-empty-buffer.js4
-rw-r--r--test/parallel/test-zlib-flush-multiple-scheduled.js2
73 files changed, 26 insertions, 140 deletions
diff --git a/test/parallel/test-assert-async.js b/test/parallel/test-assert-async.js
index 4b3664e0cb..30c9a741c6 100644
--- a/test/parallel/test-assert-async.js
+++ b/test/parallel/test-assert-async.js
@@ -5,8 +5,6 @@ const assert = require('assert');
// Test assert.rejects() and assert.doesNotReject() by checking their
// expected output and by verifying that they do not work sync
-common.crashOnUnhandledRejection();
-
// Run all tests in parallel and check their outcome at the end.
const promises = [];
diff --git a/test/parallel/test-async-hooks-disable-during-promise.js b/test/parallel/test-async-hooks-disable-during-promise.js
index ace9bca679..6b9b53bd30 100644
--- a/test/parallel/test-async-hooks-disable-during-promise.js
+++ b/test/parallel/test-async-hooks-disable-during-promise.js
@@ -1,7 +1,6 @@
'use strict';
const common = require('../common');
const async_hooks = require('async_hooks');
-common.crashOnUnhandledRejection();
if (!common.isMainThread)
common.skip('Worker bootstrapping works differently -> different AsyncWraps');
diff --git a/test/parallel/test-async-hooks-enable-during-promise.js b/test/parallel/test-async-hooks-enable-during-promise.js
index 29d25de980..ce3253b01c 100644
--- a/test/parallel/test-async-hooks-enable-during-promise.js
+++ b/test/parallel/test-async-hooks-enable-during-promise.js
@@ -2,8 +2,6 @@
const common = require('../common');
const async_hooks = require('async_hooks');
-common.crashOnUnhandledRejection();
-
Promise.resolve(1).then(common.mustCall(() => {
async_hooks.createHook({
init: common.mustCall(),
diff --git a/test/parallel/test-async-hooks-promise-enable-disable.js b/test/parallel/test-async-hooks-promise-enable-disable.js
index b7692c45cd..150ccc88b0 100644
--- a/test/parallel/test-async-hooks-promise-enable-disable.js
+++ b/test/parallel/test-async-hooks-promise-enable-disable.js
@@ -8,8 +8,6 @@ let p_resource = null;
let p_er = null;
let p_inits = 0;
-common.crashOnUnhandledRejection();
-
// Not useful to place common.mustCall() around 'exit' event b/c it won't be
// able to check it anyway.
process.on('exit', (code) => {
diff --git a/test/parallel/test-async-hooks-promise-triggerid.js b/test/parallel/test-async-hooks-promise-triggerid.js
index 507a8a4ada..467fddd359 100644
--- a/test/parallel/test-async-hooks-promise-triggerid.js
+++ b/test/parallel/test-async-hooks-promise-triggerid.js
@@ -6,8 +6,6 @@ const async_hooks = require('async_hooks');
if (!common.isMainThread)
common.skip('Worker bootstrapping works differently -> different async IDs');
-common.crashOnUnhandledRejection();
-
const promiseAsyncIds = [];
async_hooks.createHook({
diff --git a/test/parallel/test-async-wrap-pop-id-during-load.js b/test/parallel/test-async-wrap-pop-id-during-load.js
index ff3f637b87..31d2113eab 100644
--- a/test/parallel/test-async-wrap-pop-id-during-load.js
+++ b/test/parallel/test-async-wrap-pop-id-during-load.js
@@ -1,8 +1,9 @@
'use strict';
-require('../common');
+const common = require('../common');
if (process.argv[2] === 'async') {
+ common.disableCrashOnUnhandledRejection();
async function fn() {
fn();
throw new Error();
diff --git a/test/parallel/test-async-wrap-promise-after-enabled.js b/test/parallel/test-async-wrap-promise-after-enabled.js
index 5df8f13c00..0d58cbd653 100644
--- a/test/parallel/test-async-wrap-promise-after-enabled.js
+++ b/test/parallel/test-async-wrap-promise-after-enabled.js
@@ -12,8 +12,6 @@ const async_hooks = require('async_hooks');
const seenEvents = [];
-common.crashOnUnhandledRejection();
-
const p = new Promise((resolve) => resolve(1));
p.then(() => seenEvents.push('then'));
diff --git a/test/parallel/test-c-ares.js b/test/parallel/test-c-ares.js
index 59ae40b2b8..8b1cf79868 100644
--- a/test/parallel/test-c-ares.js
+++ b/test/parallel/test-c-ares.js
@@ -23,8 +23,6 @@
const common = require('../common');
const assert = require('assert');
-common.crashOnUnhandledRejection();
-
const dns = require('dns');
const dnsPromises = dns.promises;
diff --git a/test/parallel/test-child-process-promisified.js b/test/parallel/test-child-process-promisified.js
index 0fa9c68a92..877bf06662 100644
--- a/test/parallel/test-child-process-promisified.js
+++ b/test/parallel/test-child-process-promisified.js
@@ -4,8 +4,6 @@ const assert = require('assert');
const child_process = require('child_process');
const { promisify } = require('util');
-common.crashOnUnhandledRejection();
-
const exec = promisify(child_process.exec);
const execFile = promisify(child_process.execFile);
diff --git a/test/parallel/test-dns-lookup.js b/test/parallel/test-dns-lookup.js
index 5ee3bc7051..3413bcffd8 100644
--- a/test/parallel/test-dns-lookup.js
+++ b/test/parallel/test-dns-lookup.js
@@ -5,8 +5,6 @@ const cares = process.binding('cares_wrap');
const dns = require('dns');
const dnsPromises = dns.promises;
-common.crashOnUnhandledRejection();
-
// Stub `getaddrinfo` to *always* error.
cares.getaddrinfo = () => process.binding('uv').UV_ENOENT;
diff --git a/test/parallel/test-dns-promises-resolve.js b/test/parallel/test-dns-promises-resolve.js
index fcaa8977a5..430f425137 100644
--- a/test/parallel/test-dns-promises-resolve.js
+++ b/test/parallel/test-dns-promises-resolve.js
@@ -4,8 +4,6 @@ const assert = require('assert');
const dnsPromises = require('dns').promises;
-common.crashOnUnhandledRejection();
-
// Error when rrtype is invalid.
{
const rrtype = 'DUMMY';
diff --git a/test/parallel/test-dns-resolveany-bad-ancount.js b/test/parallel/test-dns-resolveany-bad-ancount.js
index d48d9385b8..4b13421b31 100644
--- a/test/parallel/test-dns-resolveany-bad-ancount.js
+++ b/test/parallel/test-dns-resolveany-bad-ancount.js
@@ -6,8 +6,6 @@ const assert = require('assert');
const dgram = require('dgram');
const dnsPromises = dns.promises;
-common.crashOnUnhandledRejection();
-
const server = dgram.createSocket('udp4');
server.on('message', common.mustCall((msg, { address, port }) => {
diff --git a/test/parallel/test-dns-resolveany.js b/test/parallel/test-dns-resolveany.js
index f9a6399cef..46694f2403 100644
--- a/test/parallel/test-dns-resolveany.js
+++ b/test/parallel/test-dns-resolveany.js
@@ -6,8 +6,6 @@ const assert = require('assert');
const dgram = require('dgram');
const dnsPromises = dns.promises;
-common.crashOnUnhandledRejection();
-
const answers = [
{ type: 'A', address: '1.2.3.4', ttl: 123 },
{ type: 'AAAA', address: '::42', ttl: 123 },
diff --git a/test/parallel/test-dns-resolvens-typeerror.js b/test/parallel/test-dns-resolvens-typeerror.js
index ec57bba614..5a72b54013 100644
--- a/test/parallel/test-dns-resolvens-typeerror.js
+++ b/test/parallel/test-dns-resolvens-typeerror.js
@@ -29,8 +29,6 @@ const common = require('../common');
const dns = require('dns');
const dnsPromises = dns.promises;
-common.crashOnUnhandledRejection();
-
common.expectsError(
() => dnsPromises.resolveNs([]), // bad name
{
diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js
index 9acf18994e..3a44be9280 100644
--- a/test/parallel/test-dns.js
+++ b/test/parallel/test-dns.js
@@ -26,8 +26,6 @@ const assert = require('assert');
const dns = require('dns');
const dnsPromises = dns.promises;
-common.crashOnUnhandledRejection();
-
const existing = dns.getServers();
assert(existing.length > 0);
diff --git a/test/parallel/test-domain-promise.js b/test/parallel/test-domain-promise.js
index f1c966d4af..1c6e629560 100644
--- a/test/parallel/test-domain-promise.js
+++ b/test/parallel/test-domain-promise.js
@@ -5,8 +5,6 @@ const domain = require('domain');
const fs = require('fs');
const vm = require('vm');
-common.crashOnUnhandledRejection();
-
{
const d = domain.create();
diff --git a/test/parallel/test-fs-lchown.js b/test/parallel/test-fs-lchown.js
index 23469eb279..bf8673c071 100644
--- a/test/parallel/test-fs-lchown.js
+++ b/test/parallel/test-fs-lchown.js
@@ -7,8 +7,6 @@ const fs = require('fs');
const path = require('path');
const { promises } = fs;
-common.crashOnUnhandledRejection();
-
// Validate the path argument.
[false, 1, {}, [], null, undefined].forEach((i) => {
const err = { type: TypeError, code: 'ERR_INVALID_ARG_TYPE' };
diff --git a/test/parallel/test-fs-promises-file-handle-append-file.js b/test/parallel/test-fs-promises-file-handle-append-file.js
index 7766ac4c90..f9abef359e 100644
--- a/test/parallel/test-fs-promises-file-handle-append-file.js
+++ b/test/parallel/test-fs-promises-file-handle-append-file.js
@@ -13,7 +13,6 @@ const assert = require('assert');
const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateAppendBuffer() {
const filePath = path.resolve(tmpDir, 'tmp-append-file-buffer.txt');
diff --git a/test/parallel/test-fs-promises-file-handle-chmod.js b/test/parallel/test-fs-promises-file-handle-chmod.js
index 8b9d8b1c0d..6b51639d41 100644
--- a/test/parallel/test-fs-promises-file-handle-chmod.js
+++ b/test/parallel/test-fs-promises-file-handle-chmod.js
@@ -13,7 +13,6 @@ const assert = require('assert');
const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateFilePermission() {
const filePath = path.resolve(tmpDir, 'tmp-chmod.txt');
diff --git a/test/parallel/test-fs-promises-file-handle-read.js b/test/parallel/test-fs-promises-file-handle-read.js
index 621e63c075..13f8c27778 100644
--- a/test/parallel/test-fs-promises-file-handle-read.js
+++ b/test/parallel/test-fs-promises-file-handle-read.js
@@ -14,7 +14,6 @@ const assert = require('assert');
const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateRead() {
const filePath = path.resolve(tmpDir, 'tmp-read-file.txt');
diff --git a/test/parallel/test-fs-promises-file-handle-readFile.js b/test/parallel/test-fs-promises-file-handle-readFile.js
index 9e6fcc2784..c31e175019 100644
--- a/test/parallel/test-fs-promises-file-handle-readFile.js
+++ b/test/parallel/test-fs-promises-file-handle-readFile.js
@@ -13,7 +13,6 @@ const assert = require('assert');
const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateReadFile() {
const filePath = path.resolve(tmpDir, 'tmp-read-file.txt');
diff --git a/test/parallel/test-fs-promises-file-handle-stat.js b/test/parallel/test-fs-promises-file-handle-stat.js
index 7d44b8e3da..19ee365213 100644
--- a/test/parallel/test-fs-promises-file-handle-stat.js
+++ b/test/parallel/test-fs-promises-file-handle-stat.js
@@ -11,7 +11,6 @@ const tmpdir = require('../common/tmpdir');
const assert = require('assert');
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateStat() {
const filePath = path.resolve(tmpdir.path, 'tmp-read-file.txt');
diff --git a/test/parallel/test-fs-promises-file-handle-sync.js b/test/parallel/test-fs-promises-file-handle-sync.js
index cf28df31cb..fc6d00c0b8 100644
--- a/test/parallel/test-fs-promises-file-handle-sync.js
+++ b/test/parallel/test-fs-promises-file-handle-sync.js
@@ -1,5 +1,5 @@
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
@@ -7,8 +7,6 @@ const tmpdir = require('../common/tmpdir');
const { access, copyFile, open } = require('fs').promises;
const path = require('path');
-common.crashOnUnhandledRejection();
-
async function validateSync() {
tmpdir.refresh();
const dest = path.resolve(tmpdir.path, 'baz.js');
diff --git a/test/parallel/test-fs-promises-file-handle-truncate.js b/test/parallel/test-fs-promises-file-handle-truncate.js
index 44d919a042..65f998db74 100644
--- a/test/parallel/test-fs-promises-file-handle-truncate.js
+++ b/test/parallel/test-fs-promises-file-handle-truncate.js
@@ -7,7 +7,6 @@ const { open, readFile } = require('fs').promises;
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateTruncate() {
const text = 'Hello world';
diff --git a/test/parallel/test-fs-promises-file-handle-write.js b/test/parallel/test-fs-promises-file-handle-write.js
index 49df2bf54f..da8cfc0a4b 100644
--- a/test/parallel/test-fs-promises-file-handle-write.js
+++ b/test/parallel/test-fs-promises-file-handle-write.js
@@ -13,7 +13,6 @@ const assert = require('assert');
const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateWrite() {
const filePathForHandle = path.resolve(tmpDir, 'tmp-write.txt');
diff --git a/test/parallel/test-fs-promises-file-handle-writeFile.js b/test/parallel/test-fs-promises-file-handle-writeFile.js
index a53384cc22..e39c59f5ca 100644
--- a/test/parallel/test-fs-promises-file-handle-writeFile.js
+++ b/test/parallel/test-fs-promises-file-handle-writeFile.js
@@ -13,7 +13,6 @@ const assert = require('assert');
const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
async function validateWriteFile() {
const filePathForHandle = path.resolve(tmpDir, 'tmp-write-file2.txt');
diff --git a/test/parallel/test-fs-promises-readfile-empty.js b/test/parallel/test-fs-promises-readfile-empty.js
index 24c17655c6..ef15a26811 100644
--- a/test/parallel/test-fs-promises-readfile-empty.js
+++ b/test/parallel/test-fs-promises-readfile-empty.js
@@ -1,5 +1,5 @@
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
const { promises: fs } = require('fs');
@@ -7,8 +7,6 @@ const fixtures = require('../common/fixtures');
const fn = fixtures.path('empty.txt');
-common.crashOnUnhandledRejection();
-
fs.readFile(fn)
.then(assert.ok);
diff --git a/test/parallel/test-fs-promises-readfile.js b/test/parallel/test-fs-promises-readfile.js
index b1186ad217..ff25be75b8 100644
--- a/test/parallel/test-fs-promises-readfile.js
+++ b/test/parallel/test-fs-promises-readfile.js
@@ -10,8 +10,6 @@ tmpdir.refresh();
const fn = path.join(tmpdir.path, 'large-file');
-common.crashOnUnhandledRejection();
-
async function validateReadFile() {
// Creating large buffer with random content
const buffer = Buffer.from(
diff --git a/test/parallel/test-fs-promises-writefile.js b/test/parallel/test-fs-promises-writefile.js
index 1bb6945c67..858e90bc62 100644
--- a/test/parallel/test-fs-promises-writefile.js
+++ b/test/parallel/test-fs-promises-writefile.js
@@ -10,8 +10,6 @@ const tmpDir = tmpdir.path;
tmpdir.refresh();
-common.crashOnUnhandledRejection();
-
const dest = path.resolve(tmpDir, 'tmp.txt');
const buffer = Buffer.from('abc'.repeat(1000));
const buffer2 = Buffer.from('xyz'.repeat(1000));
diff --git a/test/parallel/test-fs-promises.js b/test/parallel/test-fs-promises.js
index 602f1191b7..26e1f8d71c 100644
--- a/test/parallel/test-fs-promises.js
+++ b/test/parallel/test-fs-promises.js
@@ -32,16 +32,13 @@ const {
const tmpDir = tmpdir.path;
-common.crashOnUnhandledRejection();
-
// fs.promises should not be enumerable as long as it causes a warning to be
// emitted.
assert.strictEqual(Object.keys(fs).includes('promises'), false);
{
access(__filename, 'r')
- .then(common.mustCall())
- .catch(common.mustNotCall());
+ .then(common.mustCall());
access('this file does not exist', 'r')
.then(common.mustNotCall())
diff --git a/test/parallel/test-fs-promisified.js b/test/parallel/test-fs-promisified.js
index 13cf5e0e0f..0744f62fd1 100644
--- a/test/parallel/test-fs-promisified.js
+++ b/test/parallel/test-fs-promisified.js
@@ -5,8 +5,6 @@ const fs = require('fs');
const path = require('path');
const { promisify } = require('util');
-common.crashOnUnhandledRejection();
-
const read = promisify(fs.read);
const write = promisify(fs.write);
const exists = promisify(fs.exists);
diff --git a/test/parallel/test-fs-stat-bigint.js b/test/parallel/test-fs-stat-bigint.js
index 6d0a064def..943c0d55d8 100644
--- a/test/parallel/test-fs-stat-bigint.js
+++ b/test/parallel/test-fs-stat-bigint.js
@@ -8,7 +8,6 @@ const path = require('path');
const tmpdir = require('../common/tmpdir');
const { isDate } = require('util').types;
-common.crashOnUnhandledRejection();
tmpdir.refresh();
const fn = path.join(tmpdir.path, 'test-file');
diff --git a/test/parallel/test-http-agent.js b/test/parallel/test-http-agent.js
index 6dc7f75ce0..4ff781ecb9 100644
--- a/test/parallel/test-http-agent.js
+++ b/test/parallel/test-http-agent.js
@@ -24,7 +24,6 @@ const common = require('../common');
const Countdown = require('../common/countdown');
const assert = require('assert');
const http = require('http');
-common.crashOnUnhandledRejection();
const N = 4;
const M = 4;
diff --git a/test/parallel/test-http2-backpressure.js b/test/parallel/test-http2-backpressure.js
index 9b69dddbfd..db58e8da33 100644
--- a/test/parallel/test-http2-backpressure.js
+++ b/test/parallel/test-http2-backpressure.js
@@ -9,8 +9,6 @@ const assert = require('assert');
const http2 = require('http2');
const makeDuplexPair = require('../common/duplexpair');
-common.crashOnUnhandledRejection();
-
{
let req;
const server = http2.createServer();
diff --git a/test/parallel/test-http2-client-promisify-connect.js b/test/parallel/test-http2-client-promisify-connect.js
index 2eb7da3b9c..3e41bee49b 100644
--- a/test/parallel/test-http2-client-promisify-connect.js
+++ b/test/parallel/test-http2-client-promisify-connect.js
@@ -1,7 +1,6 @@
'use strict';
const common = require('../common');
-common.crashOnUnhandledRejection();
if (!common.hasCrypto)
common.skip('missing crypto');
@@ -18,7 +17,6 @@ server.listen(0, common.mustCall(() => {
const connect = util.promisify(http2.connect);
connect(`http://localhost:${server.address().port}`)
- .catch(common.mustNotCall())
.then(common.mustCall((client) => {
assert(client);
const req = client.request();
diff --git a/test/parallel/test-http2-window-size.js b/test/parallel/test-http2-window-size.js
index 3d1c14de84..164a778e1f 100644
--- a/test/parallel/test-http2-window-size.js
+++ b/test/parallel/test-http2-window-size.js
@@ -10,7 +10,6 @@ if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const h2 = require('http2');
-common.crashOnUnhandledRejection();
// Given a list of buffers and an initial window size, have a server write
// each buffer to the HTTP2 Writable stream, and let the client verify that
diff --git a/test/parallel/test-inspect-async-hook-setup-at-inspect.js b/test/parallel/test-inspect-async-hook-setup-at-inspect.js
index 6b1c875138..48de93c061 100644
--- a/test/parallel/test-inspect-async-hook-setup-at-inspect.js
+++ b/test/parallel/test-inspect-async-hook-setup-at-inspect.js
@@ -3,7 +3,6 @@
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIf32Bits();
-common.crashOnUnhandledRejection();
const { NodeInstance } = require('../common/inspector-helper.js');
const assert = require('assert');
diff --git a/test/parallel/test-inspector-esm.js b/test/parallel/test-inspector-esm.js
index 62f0feefad..d94f8d10bb 100644
--- a/test/parallel/test-inspector-esm.js
+++ b/test/parallel/test-inspector-esm.js
@@ -110,6 +110,4 @@ async function runTest() {
assert.strictEqual((await child.expectShutdown()).exitCode, 55);
}
-common.crashOnUnhandledRejection();
-
runTest();
diff --git a/test/parallel/test-inspector-multisession-js.js b/test/parallel/test-inspector-multisession-js.js
index c899eeae71..097b77e2c2 100644
--- a/test/parallel/test-inspector-multisession-js.js
+++ b/test/parallel/test-inspector-multisession-js.js
@@ -54,8 +54,6 @@ async function test() {
console.log('Sessions were disconnected');
}
-common.crashOnUnhandledRejection();
-
const interval = setInterval(() => {}, 1000);
test().then(() => {
clearInterval(interval);
diff --git a/test/parallel/test-inspector-multisession-ws.js b/test/parallel/test-inspector-multisession-ws.js
index d17adab2f4..02fde12e1c 100644
--- a/test/parallel/test-inspector-multisession-ws.js
+++ b/test/parallel/test-inspector-multisession-ws.js
@@ -70,6 +70,4 @@ async function runTest() {
return child.expectShutdown();
}
-common.crashOnUnhandledRejection();
-
runTest();
diff --git a/test/parallel/test-inspector-reported-host.js b/test/parallel/test-inspector-reported-host.js
index f54ea16625..142003e49f 100644
--- a/test/parallel/test-inspector-reported-host.js
+++ b/test/parallel/test-inspector-reported-host.js
@@ -7,8 +7,6 @@ common.skipIfInspectorDisabled();
const assert = require('assert');
const { NodeInstance } = require('../common/inspector-helper.js');
-common.crashOnUnhandledRejection();
-
async function test() {
const madeUpHost = '111.111.111.111:11111';
const child = new NodeInstance(undefined, 'var a = 1');
diff --git a/test/parallel/test-inspector-tracing-domain.js b/test/parallel/test-inspector-tracing-domain.js
index 7cbb432570..9c6fa471b5 100644
--- a/test/parallel/test-inspector-tracing-domain.js
+++ b/test/parallel/test-inspector-tracing-domain.js
@@ -65,6 +65,4 @@ async function test() {
console.log('Success');
}
-common.crashOnUnhandledRejection();
-
test();
diff --git a/test/parallel/test-internal-module-wrap.js b/test/parallel/test-internal-module-wrap.js
index bb4a648ef7..99f1e9d6e7 100644
--- a/test/parallel/test-internal-module-wrap.js
+++ b/test/parallel/test-internal-module-wrap.js
@@ -2,8 +2,7 @@
// Flags: --expose-internals
-const common = require('../common');
-common.crashOnUnhandledRejection();
+require('../common');
const assert = require('assert');
const { ModuleWrap } = require('internal/test/binding');
diff --git a/test/parallel/test-microtask-queue-integration-domain.js b/test/parallel/test-microtask-queue-integration-domain.js
index 8a4a06f9ff..98da703ee5 100644
--- a/test/parallel/test-microtask-queue-integration-domain.js
+++ b/test/parallel/test-microtask-queue-integration-domain.js
@@ -20,7 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
// Requiring the domain module here changes the function that is used by node to
@@ -30,8 +30,6 @@ const assert = require('assert');
// removed.
require('domain');
-common.crashOnUnhandledRejection();
-
const implementations = [
function(fn) {
Promise.resolve().then(fn);
diff --git a/test/parallel/test-microtask-queue-integration.js b/test/parallel/test-microtask-queue-integration.js
index a7241d99ee..57c384f8ba 100644
--- a/test/parallel/test-microtask-queue-integration.js
+++ b/test/parallel/test-microtask-queue-integration.js
@@ -20,11 +20,9 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
-common.crashOnUnhandledRejection();
-
const implementations = [
function(fn) {
Promise.resolve().then(fn);
diff --git a/test/parallel/test-microtask-queue-run-domain.js b/test/parallel/test-microtask-queue-run-domain.js
index a895504fc2..39baf93023 100644
--- a/test/parallel/test-microtask-queue-run-domain.js
+++ b/test/parallel/test-microtask-queue-run-domain.js
@@ -20,7 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
// Requiring the domain module here changes the function that is used by node to
@@ -30,8 +30,6 @@ const assert = require('assert');
// removed.
require('domain');
-common.crashOnUnhandledRejection();
-
function enqueueMicrotask(fn) {
Promise.resolve().then(fn);
}
diff --git a/test/parallel/test-microtask-queue-run-immediate-domain.js b/test/parallel/test-microtask-queue-run-immediate-domain.js
index 807affd058..60b17bc38c 100644
--- a/test/parallel/test-microtask-queue-run-immediate-domain.js
+++ b/test/parallel/test-microtask-queue-run-immediate-domain.js
@@ -20,7 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
// Requiring the domain module here changes the function that is used by node to
@@ -30,8 +30,6 @@ const assert = require('assert');
// removed.
require('domain');
-common.crashOnUnhandledRejection();
-
function enqueueMicrotask(fn) {
Promise.resolve().then(fn);
}
diff --git a/test/parallel/test-microtask-queue-run-immediate.js b/test/parallel/test-microtask-queue-run-immediate.js
index 1e26f4beeb..4d998cf0b8 100644
--- a/test/parallel/test-microtask-queue-run-immediate.js
+++ b/test/parallel/test-microtask-queue-run-immediate.js
@@ -20,11 +20,9 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
-common.crashOnUnhandledRejection();
-
function enqueueMicrotask(fn) {
Promise.resolve().then(fn);
}
diff --git a/test/parallel/test-microtask-queue-run.js b/test/parallel/test-microtask-queue-run.js
index ba9cf6731e..85eb770da1 100644
--- a/test/parallel/test-microtask-queue-run.js
+++ b/test/parallel/test-microtask-queue-run.js
@@ -20,11 +20,9 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
-common.crashOnUnhandledRejection();
-
function enqueueMicrotask(fn) {
Promise.resolve().then(fn);
}
diff --git a/test/parallel/test-net-server-max-connections-close-makes-more-available.js b/test/parallel/test-net-server-max-connections-close-makes-more-available.js
index eb045c704c..f607f28c10 100644
--- a/test/parallel/test-net-server-max-connections-close-makes-more-available.js
+++ b/test/parallel/test-net-server-max-connections-close-makes-more-available.js
@@ -1,9 +1,8 @@
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
const net = require('net');
-common.crashOnUnhandledRejection();
// Sets the server's maxConnections property to 1.
// Open 2 connections (connection 0 and connection 1).
@@ -84,8 +83,3 @@ process.on('exit', function() {
// ...but that only connections 0 and 2 were successful.
assert.deepStrictEqual(received, ['0', '2']);
});
-
-process.on('unhandledRejection', function() {
- console.error('promise rejected');
- assert.fail('A promise in the chain rejected');
-});
diff --git a/test/parallel/test-promises-unhandled-proxy-rejections.js b/test/parallel/test-promises-unhandled-proxy-rejections.js
index dfd1ee322a..83062e9520 100644
--- a/test/parallel/test-promises-unhandled-proxy-rejections.js
+++ b/test/parallel/test-promises-unhandled-proxy-rejections.js
@@ -1,6 +1,8 @@
'use strict';
const common = require('../common');
+common.disableCrashOnUnhandledRejection();
+
const expectedDeprecationWarning = ['Unhandled promise rejections are ' +
'deprecated. In the future, promise ' +
'rejections that are not handled will ' +
diff --git a/test/parallel/test-promises-unhandled-rejections.js b/test/parallel/test-promises-unhandled-rejections.js
index 1ade061994..92b6d7a961 100644
--- a/test/parallel/test-promises-unhandled-rejections.js
+++ b/test/parallel/test-promises-unhandled-rejections.js
@@ -1,8 +1,10 @@
'use strict';
-require('../common');
+const common = require('../common');
const assert = require('assert');
const domain = require('domain');
+common.disableCrashOnUnhandledRejection();
+
const asyncTest = (function() {
let asyncTestsEnabled = false;
let asyncTestLastCheck;
diff --git a/test/parallel/test-promises-unhandled-symbol-rejections.js b/test/parallel/test-promises-unhandled-symbol-rejections.js
index e5084b50c1..2102de8191 100644
--- a/test/parallel/test-promises-unhandled-symbol-rejections.js
+++ b/test/parallel/test-promises-unhandled-symbol-rejections.js
@@ -1,6 +1,8 @@
'use strict';
const common = require('../common');
+common.disableCrashOnUnhandledRejection();
+
const expectedValueWarning = ['Symbol()', common.noWarnCode];
const expectedDeprecationWarning = ['Unhandled promise rejections are ' +
'deprecated. In the future, promise ' +
diff --git a/test/parallel/test-promises-warning-on-unhandled-rejection.js b/test/parallel/test-promises-warning-on-unhandled-rejection.js
index 3ac7d8698b..ba420157e7 100644
--- a/test/parallel/test-promises-warning-on-unhandled-rejection.js
+++ b/test/parallel/test-promises-warning-on-unhandled-rejection.js
@@ -7,6 +7,8 @@
const common = require('../common');
const assert = require('assert');
+common.disableCrashOnUnhandledRejection();
+
let b = 0;
process.on('warning', common.mustCall((warning) => {
diff --git a/test/parallel/test-repl-load-multiline.js b/test/parallel/test-repl-load-multiline.js
index 8ab878ae76..fd58a3c21d 100644
--- a/test/parallel/test-repl-load-multiline.js
+++ b/test/parallel/test-repl-load-multiline.js
@@ -4,8 +4,6 @@ const fixtures = require('../common/fixtures');
const assert = require('assert');
const repl = require('repl');
-common.crashOnUnhandledRejection();
-
const command = `.load ${fixtures.path('repl-load-multiline.js')}`;
const terminalCode = '\u001b[1G\u001b[0J \u001b[1G';
const terminalCodeRegex = new RegExp(terminalCode.replace(/\[/g, '\\['), 'g');
diff --git a/test/parallel/test-repl-top-level-await.js b/test/parallel/test-repl-top-level-await.js
index 5a07f5ced1..f1e2303938 100644
--- a/test/parallel/test-repl-top-level-await.js
+++ b/test/parallel/test-repl-top-level-await.js
@@ -5,8 +5,6 @@ const assert = require('assert');
const { stripVTControlCharacters } = require('internal/readline');
const repl = require('repl');
-common.crashOnUnhandledRejection();
-
// Flags: --expose-internals --experimental-repl-await
const PROMPT = 'await repl > ';
diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js
index 5459371f00..35cd3e11af 100644
--- a/test/parallel/test-repl.js
+++ b/test/parallel/test-repl.js
@@ -26,8 +26,6 @@ const assert = require('assert');
const net = require('net');
const repl = require('repl');
-common.crashOnUnhandledRejection();
-
const message = 'Read, Eval, Print Loop';
const prompt_unix = 'node via Unix socket> ';
const prompt_tcp = 'node via TCP socket> ';
diff --git a/test/parallel/test-stream-finished.js b/test/parallel/test-stream-finished.js
index 2b0c156eb0..3aade5610c 100644
--- a/test/parallel/test-stream-finished.js
+++ b/test/parallel/test-stream-finished.js
@@ -6,8 +6,6 @@ const assert = require('assert');
const fs = require('fs');
const { promisify } = require('util');
-common.crashOnUnhandledRejection();
-
{
const rs = new Readable({
read() {}
diff --git a/test/parallel/test-stream-pipeline.js b/test/parallel/test-stream-pipeline.js
index f735054e88..6f9bca811f 100644
--- a/test/parallel/test-stream-pipeline.js
+++ b/test/parallel/test-stream-pipeline.js
@@ -9,8 +9,6 @@ const http = require('http');
const http2 = require('http2');
const { promisify } = require('util');
-common.crashOnUnhandledRejection();
-
{
let finished = false;
const processed = [];
diff --git a/test/parallel/test-stream-readable-async-iterators.js b/test/parallel/test-stream-readable-async-iterators.js
index 39761b4132..d8eb83a585 100644
--- a/test/parallel/test-stream-readable-async-iterators.js
+++ b/test/parallel/test-stream-readable-async-iterators.js
@@ -4,8 +4,6 @@ const common = require('../common');
const { Readable } = require('stream');
const assert = require('assert');
-common.crashOnUnhandledRejection();
-
async function tests() {
await (async function() {
console.log('read without for..await');
diff --git a/test/parallel/test-timers-promisified.js b/test/parallel/test-timers-promisified.js
index 1dad1d8cfc..85e7093cfa 100644
--- a/test/parallel/test-timers-promisified.js
+++ b/test/parallel/test-timers-promisified.js
@@ -6,8 +6,6 @@ const { promisify } = require('util');
/* eslint-disable no-restricted-syntax */
-common.crashOnUnhandledRejection();
-
const setTimeout = promisify(timers.setTimeout);
const setImmediate = promisify(timers.setImmediate);
diff --git a/test/parallel/test-util-inspect-namespace.js b/test/parallel/test-util-inspect-namespace.js
index fddbcdb346..e73f475cff 100644
--- a/test/parallel/test-util-inspect-namespace.js
+++ b/test/parallel/test-util-inspect-namespace.js
@@ -2,11 +2,9 @@
// Flags: --experimental-vm-modules
-const common = require('../common');
+require('../common');
const assert = require('assert');
-common.crashOnUnhandledRejection();
-
const { Module } = require('vm');
const { inspect } = require('util');
diff --git a/test/parallel/test-util-promisify.js b/test/parallel/test-util-promisify.js
index 5e1994a730..0bece0df42 100644
--- a/test/parallel/test-util-promisify.js
+++ b/test/parallel/test-util-promisify.js
@@ -7,8 +7,6 @@ const vm = require('vm');
const { promisify } = require('util');
const { customPromisifyArgs } = require('internal/util');
-common.crashOnUnhandledRejection();
-
const stat = promisify(fs.stat);
{
diff --git a/test/parallel/test-util-types.js b/test/parallel/test-util-types.js
index de5a89ab4a..59a9dcceb5 100644
--- a/test/parallel/test-util-types.js
+++ b/test/parallel/test-util-types.js
@@ -1,14 +1,12 @@
// Flags: --harmony-bigint --experimental-vm-modules
'use strict';
-const common = require('../common');
+require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const { types, inspect } = require('util');
const vm = require('vm');
const { JSStream } = process.binding('js_stream');
-common.crashOnUnhandledRejection();
-
const external = (new JSStream())._externalStream;
const wasmBuffer = fixtures.readSync('test.wasm');
diff --git a/test/parallel/test-vm-module-basic.js b/test/parallel/test-vm-module-basic.js
index 4bbe0a95ee..1f699ddf5b 100644
--- a/test/parallel/test-vm-module-basic.js
+++ b/test/parallel/test-vm-module-basic.js
@@ -6,8 +6,6 @@ const common = require('../common');
const assert = require('assert');
const { Module, createContext } = require('vm');
-common.crashOnUnhandledRejection();
-
(async function test1() {
const context = createContext({
foo: 'bar',
diff --git a/test/parallel/test-vm-module-dynamic-import.js b/test/parallel/test-vm-module-dynamic-import.js
index ca4dceb5de..bb45337cf1 100644
--- a/test/parallel/test-vm-module-dynamic-import.js
+++ b/test/parallel/test-vm-module-dynamic-import.js
@@ -3,7 +3,6 @@
// Flags: --experimental-vm-modules --experimental-modules --harmony-dynamic-import
const common = require('../common');
-common.crashOnUnhandledRejection();
const assert = require('assert');
const { Module, createContext } = require('vm');
diff --git a/test/parallel/test-vm-module-errors.js b/test/parallel/test-vm-module-errors.js
index 424d35e8aa..720f28525b 100644
--- a/test/parallel/test-vm-module-errors.js
+++ b/test/parallel/test-vm-module-errors.js
@@ -3,7 +3,6 @@
// Flags: --experimental-vm-modules
const common = require('../common');
-common.crashOnUnhandledRejection();
const assert = require('assert');
diff --git a/test/parallel/test-vm-module-import-meta.js b/test/parallel/test-vm-module-import-meta.js
index 835ef5b6eb..5e97f1ac54 100644
--- a/test/parallel/test-vm-module-import-meta.js
+++ b/test/parallel/test-vm-module-import-meta.js
@@ -6,8 +6,6 @@ const common = require('../common');
const assert = require('assert');
const { Module } = require('vm');
-common.crashOnUnhandledRejection();
-
async function testBasic() {
const m = new Module('import.meta;', {
initializeImportMeta: common.mustCall((meta, module) => {
diff --git a/test/parallel/test-vm-module-link.js b/test/parallel/test-vm-module-link.js
index d9ee8e7767..ead6721bd4 100644
--- a/test/parallel/test-vm-module-link.js
+++ b/test/parallel/test-vm-module-link.js
@@ -3,7 +3,6 @@
// Flags: --experimental-vm-modules
const common = require('../common');
-common.crashOnUnhandledRejection();
const assert = require('assert');
const { URL } = require('url');
diff --git a/test/parallel/test-vm-module-reevaluate.js b/test/parallel/test-vm-module-reevaluate.js
index e4f5858800..e08ab73450 100644
--- a/test/parallel/test-vm-module-reevaluate.js
+++ b/test/parallel/test-vm-module-reevaluate.js
@@ -3,7 +3,6 @@
// Flags: --experimental-vm-modules
const common = require('../common');
-common.crashOnUnhandledRejection();
const assert = require('assert');
diff --git a/test/parallel/test-wasm-simple.js b/test/parallel/test-wasm-simple.js
index 02a97ec2c9..f00f10c436 100644
--- a/test/parallel/test-wasm-simple.js
+++ b/test/parallel/test-wasm-simple.js
@@ -1,11 +1,9 @@
'use strict';
-const common = require('../common');
+require('../common');
const assert = require('assert');
const fixtures = require('../common/fixtures');
-common.crashOnUnhandledRejection();
-
const buffer = fixtures.readSync('test.wasm');
assert.ok(WebAssembly.validate(buffer), 'Buffer should be valid WebAssembly');
diff --git a/test/parallel/test-zlib-empty-buffer.js b/test/parallel/test-zlib-empty-buffer.js
index 8b299f8728..e351db5457 100644
--- a/test/parallel/test-zlib-empty-buffer.js
+++ b/test/parallel/test-zlib-empty-buffer.js
@@ -1,12 +1,10 @@
'use strict';
-const common = require('../common');
+require('../common');
const zlib = require('zlib');
const { inspect, promisify } = require('util');
const assert = require('assert');
const emptyBuffer = Buffer.alloc(0);
-common.crashOnUnhandledRejection();
-
(async function() {
for (const [ compress, decompress, method ] of [
[ zlib.deflateRawSync, zlib.inflateRawSync, 'raw sync' ],
diff --git a/test/parallel/test-zlib-flush-multiple-scheduled.js b/test/parallel/test-zlib-flush-multiple-scheduled.js
index 1954867238..0b752557e4 100644
--- a/test/parallel/test-zlib-flush-multiple-scheduled.js
+++ b/test/parallel/test-zlib-flush-multiple-scheduled.js
@@ -8,8 +8,6 @@ const {
Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH
} = zlib.constants;
-common.crashOnUnhandledRejection();
-
async function getOutput(...sequenceOfFlushes) {
const zipper = zlib.createGzip({ highWaterMark: 16384 });