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>
This commit is contained in:
Michaël Zasso committed 2018-07-19 08:47:28 +02:00
1 parent 373aae1f86
commit df08779e0d
117 files changed
+58 -241

No files matched your search

+9 -19
View File
@@ -225,34 +225,24 @@ countdown.dec(); // The countdown callback will be invoked now.
#### Testing promises
When writing tests involving promises, either make sure that the
`onFulfilled` or the `onRejected` handler is wrapped in
`common.mustCall()` or `common.mustNotCall()` accordingly, or
call `common.crashOnUnhandledRejection()` in the top level of the
test to make sure that unhandled rejections would result in a test
failure. For example:
When writing tests involving promises, it is generally good to wrap the
`onFulfilled` handler, otherwise the test could successfully finish if the
promise never resolves (pending promises do not keep the event loop alive). The
`common` module automatically adds a handler that makes the process crash - and
hence, the test fail - in the case of an `unhandledRejection` event. It is
possible to disable it with `common.disableCrashOnUnhandledRejection()` if
needed.
```javascript
const common = require('../common');
const assert = require('assert');
const fs = require('fs').promises;
// Use `common.crashOnUnhandledRejection()` to make sure unhandled rejections
// will fail the test.
common.crashOnUnhandledRejection();
// Or, wrap the `onRejected` handler in `common.mustNotCall()`.
fs.writeFile('test-file', 'test').catch(common.mustNotCall());
// Or, wrap the `onFulfilled` handler in `common.mustCall()`.
// If there are assertions in the `onFulfilled` handler, wrap
// the next `onRejected` handler in `common.mustNotCall()`
// to handle potential failures.
// Wrap the `onFulfilled` handler in `common.mustCall()`.
fs.readFile('test-file').then(
common.mustCall(
(content) => assert.strictEqual(content.toString(), 'test2')
))
.catch(common.mustNotCall());
));
```
### Flags
-2
View File
@@ -7,8 +7,6 @@ const common = require('../../common');
const assert = require('assert');
const test_promise = require(`./build/${common.buildType}/test_promise`);
common.crashOnUnhandledRejection();
// A resolution
{
const expected_result = 42;
@@ -12,8 +12,6 @@ const expectedArray = (function(arrayLength) {
return result;
})(binding.ARRAY_LENGTH);
common.crashOnUnhandledRejection();
// Handle the rapid teardown test case as the child process. We unref the
// thread-safe function after we have received two values. This causes the
// process to exit and the environment cleanup handler to be invoked.
@@ -4,8 +4,6 @@ const common = require('../../common');
const assert = require('assert');
const { testResolveAsync } = require(`./build/${common.buildType}/binding`);
common.crashOnUnhandledRejection();
let called = false;
testResolveAsync().then(() => { called = true; });
@@ -9,8 +9,6 @@ const makeCallback = binding.makeCallback;
// Make sure this is run in the future.
const mustCallCheckDomains = common.mustCall(checkDomains);
common.crashOnUnhandledRejection();
// Make sure that using MakeCallback allows the error to propagate.
assert.throws(function() {
makeCallback({}, function() {
@@ -8,8 +8,6 @@ const { checkInvocations } = require('./hook-checks');
if (!common.isMainThread)
common.skip('Worker bootstrapping works differently -> different async IDs');
common.crashOnUnhandledRejection();
const p = new Promise(common.mustCall(function executor(resolve, reject) {
resolve(5);
}));
-2
View File
@@ -9,8 +9,6 @@ const { checkInvocations } = require('./hook-checks');
if (!common.isMainThread)
common.skip('Worker bootstrapping works differently -> different async IDs');
common.crashOnUnhandledRejection();
const hooks = initHooks();
hooks.enable();
+8 -7
View File
@@ -55,18 +55,19 @@ 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()
Installs a `process.on('unhandledRejection')` handler that crashes the process
after a tick. This is useful for tests that use Promises and need to make sure
no unexpected rejections occur, because currently they result in silent
failures.
### ddCommand(filename, kilobytes)
* return [&lt;Object>]
Platform normalizes the `dd` command
### disableCrashOnUnhandledRejection()
Removes the `process.on('unhandledRejection')` handler that crashes the process
after a tick. The handler is useful for tests that use Promises and need to make
sure no unexpected rejections occur, because currently they result in silent
failures. However, it is useful in some rare cases to disable it, for example if
the `unhandledRejection` hook is directly used by the test.
### enoughTestMem
* [&lt;boolean>]
+4 -3
View File
@@ -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);
exports.disableCrashOnUnhandledRejection = function() {
process.removeListener('unhandledRejection', crashOnUnhandledRejection);
};
exports.getTTYfd = function getTTYfd() {
+2 -2
View File
@@ -52,7 +52,7 @@ const {
skipIf32Bits,
getArrayBufferViews,
getBufferSources,
crashOnUnhandledRejection,
disableCrashOnUnhandledRejection,
getTTYfd,
runWithInvalidFD,
hijackStdout,
@@ -112,7 +112,7 @@ export {
skipIf32Bits,
getArrayBufferViews,
getBufferSources,
crashOnUnhandledRejection,
disableCrashOnUnhandledRejection,
getTTYfd,
runWithInvalidFD,
hijackStdout,
+1
View File
@@ -25,6 +25,7 @@ function spawnChildProcess(inspectorFlags, scriptContents, scriptFile) {
const handler = tearDown.bind(null, child);
process.on('exit', handler);
process.on('uncaughtException', handler);
common.disableCrashOnUnhandledRejection();
process.on('unhandledRejection', handler);
process.on('SIGINT', handler);
@@ -5,8 +5,6 @@ const assert = require('assert');
const { URL } = require('url');
const vm = require('vm');
common.crashOnUnhandledRejection();
const relativePath = '../fixtures/es-modules/test-esm-ok.mjs';
const absolutePath = require.resolve('../fixtures/es-modules/test-esm-ok.mjs');
const targetURL = new URL('file:///');
+1 -3
View File
@@ -2,11 +2,9 @@
// Flags: --experimental-modules
const common = require('../common');
require('../common');
const assert = require('assert');
common.crashOnUnhandledRejection();
const file = '../fixtures/syntax/bad_syntax.js';
let error;
@@ -1,11 +1,6 @@
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs
import {
crashOnUnhandledRejection,
expectsError
} from '../common';
crashOnUnhandledRejection();
import { expectsError } from '../common';
import('test').catch(expectsError({
code: 'ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK',
+1 -3
View File
@@ -1,6 +1,5 @@
// Flags: --experimental-modules
/* eslint-disable node-core/required-modules */
import common from '../common/index.js';
import '../common';
import assert from 'assert';
async function doTest() {
@@ -12,5 +11,4 @@ async function doTest() {
);
}
common.crashOnUnhandledRejection();
doTest();
-2
View File
@@ -9,8 +9,6 @@ const net = require('net');
let running = false;
const queue = [];
common.crashOnUnhandledRejection();
const dnsPromises = dns.promises;
const isIPv4 = net.isIPv4;
const isIPv6 = net.isIPv6;
-2
View File
@@ -7,8 +7,6 @@ const net = require('net');
const util = require('util');
const isIPv4 = net.isIPv4;
common.crashOnUnhandledRejection();
const dnsPromises = dns.promises;
let running = false;
const queue = [];
-2
View File
@@ -4,8 +4,6 @@ const { addresses } = require('../common/internet');
if (!common.hasIPv6)
common.skip('this test, no IPv6 support');
common.crashOnUnhandledRejection();
const assert = require('assert');
const dns = require('dns');
const net = require('net');
+1 -3
View File
@@ -1,11 +1,9 @@
'use strict';
const common = require('../common');
require('../common');
const assert = require('assert');
const dns = require('dns');
const dnsPromises = dns.promises;
common.crashOnUnhandledRejection();
(async function() {
const result = await dnsPromises.resolveTxt('www.microsoft.com');
assert.strictEqual(result.length, 0);
-2
View File
@@ -30,8 +30,6 @@ const isIPv6 = net.isIPv6;
const util = require('util');
const dnsPromises = dns.promises;
common.crashOnUnhandledRejection();
let expected = 0;
let completed = 0;
let running = false;
@@ -23,8 +23,6 @@ if (process.config.variables.v8_enable_inspector === 0) {
const cluster = require('cluster');
const net = require('net');
common.crashOnUnhandledRejection();
const ports = [process.debugPort];
const clashPort = process.debugPort + 2;
function serialFork() {
@@ -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(() => {}));
-2
View File
@@ -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 = [];
@@ -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');
@@ -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(),
@@ -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) => {
@@ -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({
@@ -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();
@@ -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'));
-2
View File
@@ -23,8 +23,6 @@
const common = require('../common');
const assert = require('assert');
common.crashOnUnhandledRejection();
const dns = require('dns');
const dnsPromises = dns.promises;
@@ -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);
-2
View File
@@ -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;
@@ -4,8 +4,6 @@ const assert = require('assert');
const dnsPromises = require('dns').promises;
common.crashOnUnhandledRejection();
// Error when rrtype is invalid.
{
const rrtype = 'DUMMY';
@@ -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 }) => {
-2
View File
@@ -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 },
@@ -29,8 +29,6 @@ const common = require('../common');
const dns = require('dns');
const dnsPromises = dns.promises;
common.crashOnUnhandledRejection();
common.expectsError(
() => dnsPromises.resolveNs([]), // bad name
{
-2
View File
@@ -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);
-2
View File
@@ -5,8 +5,6 @@ const domain = require('domain');
const fs = require('fs');
const vm = require('vm');
common.crashOnUnhandledRejection();
{
const d = domain.create();
-2
View File
@@ -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' };
@@ -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');
@@ -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');
@@ -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');
@@ -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');
@@ -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');
@@ -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');
@@ -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';
@@ -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');
@@ -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');
@@ -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);
@@ -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(
@@ -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));
+1 -4
View File
@@ -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())
-2
View File
@@ -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);
-1
View File
@@ -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');
-1
View File
@@ -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;
-2
View File
@@ -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();
@@ -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();
-1
View File
@@ -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
@@ -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');
-2
View File
@@ -110,6 +110,4 @@ async function runTest() {
assert.strictEqual((await child.expectShutdown()).exitCode, 55);
}
common.crashOnUnhandledRejection();
runTest();
@@ -54,8 +54,6 @@ async function test() {
console.log('Sessions were disconnected');
}
common.crashOnUnhandledRejection();
const interval = setInterval(() => {}, 1000);
test().then(() => {
clearInterval(interval);
@@ -70,6 +70,4 @@ async function runTest() {
return child.expectShutdown();
}
common.crashOnUnhandledRejection();
runTest();
@@ -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');
@@ -65,6 +65,4 @@ async function test() {
console.log('Success');
}
common.crashOnUnhandledRejection();
test();
+1 -2
View File
@@ -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');
@@ -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);
@@ -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);
@@ -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);
}
@@ -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);
}
@@ -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);
}
+1 -3
View File
@@ -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);
}
@@ -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');
});
@@ -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 ' +
@@ -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;
@@ -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 ' +
@@ -7,6 +7,8 @@
const common = require('../common');
const assert = require('assert');
common.disableCrashOnUnhandledRejection();
let b = 0;
process.on('warning', common.mustCall((warning) => {
@@ -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');
@@ -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 > ';
-2
View File
@@ -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> ';
-2
View File
@@ -6,8 +6,6 @@ const assert = require('assert');
const fs = require('fs');
const { promisify } = require('util');
common.crashOnUnhandledRejection();
{
const rs = new Readable({
read() {}
-2
View File
@@ -9,8 +9,6 @@ const http = require('http');
const http2 = require('http2');
const { promisify } = require('util');
common.crashOnUnhandledRejection();
{
let finished = false;
const processed = [];
@@ -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');
-2
View File
@@ -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);
+1 -3
View File
@@ -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');
-2
View File
@@ -7,8 +7,6 @@ const vm = require('vm');
const { promisify } = require('util');
const { customPromisifyArgs } = require('internal/util');
common.crashOnUnhandledRejection();
const stat = promisify(fs.stat);
{
+1 -3
View File
@@ -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');
-2
View File
@@ -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',
@@ -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');
-1
View File
@@ -3,7 +3,6 @@
// Flags: --experimental-vm-modules
const common = require('../common');
common.crashOnUnhandledRejection();
const assert = require('assert');
@@ -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) => {
-1
View File
@@ -3,7 +3,6 @@
// Flags: --experimental-vm-modules
const common = require('../common');
common.crashOnUnhandledRejection();
const assert = require('assert');
const { URL } = require('url');
@@ -3,7 +3,6 @@
// Flags: --experimental-vm-modules
const common = require('../common');
common.crashOnUnhandledRejection();
const assert = require('assert');
+1 -3
View File
@@ -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');
+1 -3
View File
@@ -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' ],
@@ -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 });
@@ -11,8 +11,6 @@ const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
const { getSystemErrorName } = require('util');
common.crashOnUnhandledRejection();
// Make sure that all Providers are tested.
{
const hooks = require('async_hooks').createHook({
@@ -198,7 +196,7 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
testInitialized(fd, 'FileHandle');
await fd.close();
}
openTest().then(common.mustCall()).catch(common.mustNotCall());
openTest().then(common.mustCall());
}
{
@@ -9,6 +9,7 @@ const { strictEqual } = require('assert');
const eyecatcher = 'nou, houdoe he?';
if (process.argv[2] === 'child') {
common.disableCrashOnUnhandledRejection();
const { Session } = require('inspector');
const { promisify } = require('util');
const { registerAsyncHook } = process.binding('inspector');
@@ -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');
@@ -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');
@@ -3,7 +3,6 @@
const common = require('../common');
common.skipIfInspectorDisabled();
common.skipIf32Bits();
common.crashOnUnhandledRejection();
const { NodeInstance } = require('../common/inspector-helper');
const assert = require('assert');
Loaded 100 of 117 files, more files were not shown because too many files have changed in this diff. Show more