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:
parent
373aae1f86
commit
df08779e0d
@ -225,34 +225,24 @@ countdown.dec(); // The countdown callback will be invoked now.
|
|||||||
|
|
||||||
#### Testing promises
|
#### Testing promises
|
||||||
|
|
||||||
When writing tests involving promises, either make sure that the
|
When writing tests involving promises, it is generally good to wrap the
|
||||||
`onFulfilled` or the `onRejected` handler is wrapped in
|
`onFulfilled` handler, otherwise the test could successfully finish if the
|
||||||
`common.mustCall()` or `common.mustNotCall()` accordingly, or
|
promise never resolves (pending promises do not keep the event loop alive). The
|
||||||
call `common.crashOnUnhandledRejection()` in the top level of the
|
`common` module automatically adds a handler that makes the process crash - and
|
||||||
test to make sure that unhandled rejections would result in a test
|
hence, the test fail - in the case of an `unhandledRejection` event. It is
|
||||||
failure. For example:
|
possible to disable it with `common.disableCrashOnUnhandledRejection()` if
|
||||||
|
needed.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs').promises;
|
const fs = require('fs').promises;
|
||||||
|
|
||||||
// Use `common.crashOnUnhandledRejection()` to make sure unhandled rejections
|
// Wrap the `onFulfilled` handler in `common.mustCall()`.
|
||||||
// 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.
|
|
||||||
fs.readFile('test-file').then(
|
fs.readFile('test-file').then(
|
||||||
common.mustCall(
|
common.mustCall(
|
||||||
(content) => assert.strictEqual(content.toString(), 'test2')
|
(content) => assert.strictEqual(content.toString(), 'test2')
|
||||||
))
|
));
|
||||||
.catch(common.mustNotCall());
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Flags
|
### Flags
|
||||||
|
@ -7,8 +7,6 @@ const common = require('../../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const test_promise = require(`./build/${common.buildType}/test_promise`);
|
const test_promise = require(`./build/${common.buildType}/test_promise`);
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
// A resolution
|
// A resolution
|
||||||
{
|
{
|
||||||
const expected_result = 42;
|
const expected_result = 42;
|
||||||
|
@ -12,8 +12,6 @@ const expectedArray = (function(arrayLength) {
|
|||||||
return result;
|
return result;
|
||||||
})(binding.ARRAY_LENGTH);
|
})(binding.ARRAY_LENGTH);
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
// Handle the rapid teardown test case as the child process. We unref the
|
// 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
|
// thread-safe function after we have received two values. This causes the
|
||||||
// process to exit and the environment cleanup handler to be invoked.
|
// process to exit and the environment cleanup handler to be invoked.
|
||||||
|
@ -4,8 +4,6 @@ const common = require('../../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { testResolveAsync } = require(`./build/${common.buildType}/binding`);
|
const { testResolveAsync } = require(`./build/${common.buildType}/binding`);
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
let called = false;
|
let called = false;
|
||||||
testResolveAsync().then(() => { called = true; });
|
testResolveAsync().then(() => { called = true; });
|
||||||
|
|
||||||
|
@ -9,8 +9,6 @@ const makeCallback = binding.makeCallback;
|
|||||||
// Make sure this is run in the future.
|
// Make sure this is run in the future.
|
||||||
const mustCallCheckDomains = common.mustCall(checkDomains);
|
const mustCallCheckDomains = common.mustCall(checkDomains);
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
// Make sure that using MakeCallback allows the error to propagate.
|
// Make sure that using MakeCallback allows the error to propagate.
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
makeCallback({}, function() {
|
makeCallback({}, function() {
|
||||||
|
@ -8,8 +8,6 @@ const { checkInvocations } = require('./hook-checks');
|
|||||||
if (!common.isMainThread)
|
if (!common.isMainThread)
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const p = new Promise(common.mustCall(function executor(resolve, reject) {
|
const p = new Promise(common.mustCall(function executor(resolve, reject) {
|
||||||
resolve(5);
|
resolve(5);
|
||||||
}));
|
}));
|
||||||
|
@ -9,8 +9,6 @@ const { checkInvocations } = require('./hook-checks');
|
|||||||
if (!common.isMainThread)
|
if (!common.isMainThread)
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const hooks = initHooks();
|
const hooks = initHooks();
|
||||||
|
|
||||||
hooks.enable();
|
hooks.enable();
|
||||||
|
@ -55,18 +55,19 @@ symlinks
|
|||||||
([SeCreateSymbolicLinkPrivilege](https://msdn.microsoft.com/en-us/library/windows/desktop/bb530716(v=vs.85).aspx)).
|
([SeCreateSymbolicLinkPrivilege](https://msdn.microsoft.com/en-us/library/windows/desktop/bb530716(v=vs.85).aspx)).
|
||||||
On non-Windows platforms, this always returns `true`.
|
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)
|
### ddCommand(filename, kilobytes)
|
||||||
* return [<Object>]
|
* return [<Object>]
|
||||||
|
|
||||||
Platform normalizes the `dd` command
|
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
|
### enoughTestMem
|
||||||
* [<boolean>]
|
* [<boolean>]
|
||||||
|
|
||||||
|
@ -814,9 +814,10 @@ exports.getBufferSources = function getBufferSources(buf) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Crash the process on unhandled rejections.
|
// Crash the process on unhandled rejections.
|
||||||
exports.crashOnUnhandledRejection = function() {
|
const crashOnUnhandledRejection = (err) => { throw err; };
|
||||||
process.on('unhandledRejection',
|
process.on('unhandledRejection', crashOnUnhandledRejection);
|
||||||
(err) => process.nextTick(() => { throw err; }));
|
exports.disableCrashOnUnhandledRejection = function() {
|
||||||
|
process.removeListener('unhandledRejection', crashOnUnhandledRejection);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.getTTYfd = function getTTYfd() {
|
exports.getTTYfd = function getTTYfd() {
|
||||||
|
@ -52,7 +52,7 @@ const {
|
|||||||
skipIf32Bits,
|
skipIf32Bits,
|
||||||
getArrayBufferViews,
|
getArrayBufferViews,
|
||||||
getBufferSources,
|
getBufferSources,
|
||||||
crashOnUnhandledRejection,
|
disableCrashOnUnhandledRejection,
|
||||||
getTTYfd,
|
getTTYfd,
|
||||||
runWithInvalidFD,
|
runWithInvalidFD,
|
||||||
hijackStdout,
|
hijackStdout,
|
||||||
@ -112,7 +112,7 @@ export {
|
|||||||
skipIf32Bits,
|
skipIf32Bits,
|
||||||
getArrayBufferViews,
|
getArrayBufferViews,
|
||||||
getBufferSources,
|
getBufferSources,
|
||||||
crashOnUnhandledRejection,
|
disableCrashOnUnhandledRejection,
|
||||||
getTTYfd,
|
getTTYfd,
|
||||||
runWithInvalidFD,
|
runWithInvalidFD,
|
||||||
hijackStdout,
|
hijackStdout,
|
||||||
|
@ -25,6 +25,7 @@ function spawnChildProcess(inspectorFlags, scriptContents, scriptFile) {
|
|||||||
const handler = tearDown.bind(null, child);
|
const handler = tearDown.bind(null, child);
|
||||||
process.on('exit', handler);
|
process.on('exit', handler);
|
||||||
process.on('uncaughtException', handler);
|
process.on('uncaughtException', handler);
|
||||||
|
common.disableCrashOnUnhandledRejection();
|
||||||
process.on('unhandledRejection', handler);
|
process.on('unhandledRejection', handler);
|
||||||
process.on('SIGINT', handler);
|
process.on('SIGINT', handler);
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ const assert = require('assert');
|
|||||||
const { URL } = require('url');
|
const { URL } = require('url');
|
||||||
const vm = require('vm');
|
const vm = require('vm');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const relativePath = '../fixtures/es-modules/test-esm-ok.mjs';
|
const relativePath = '../fixtures/es-modules/test-esm-ok.mjs';
|
||||||
const absolutePath = require.resolve('../fixtures/es-modules/test-esm-ok.mjs');
|
const absolutePath = require.resolve('../fixtures/es-modules/test-esm-ok.mjs');
|
||||||
const targetURL = new URL('file:///');
|
const targetURL = new URL('file:///');
|
||||||
|
@ -2,11 +2,9 @@
|
|||||||
|
|
||||||
// Flags: --experimental-modules
|
// Flags: --experimental-modules
|
||||||
|
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const file = '../fixtures/syntax/bad_syntax.js';
|
const file = '../fixtures/syntax/bad_syntax.js';
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs
|
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs
|
||||||
|
|
||||||
import {
|
import { expectsError } from '../common';
|
||||||
crashOnUnhandledRejection,
|
|
||||||
expectsError
|
|
||||||
} from '../common';
|
|
||||||
|
|
||||||
crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
import('test').catch(expectsError({
|
import('test').catch(expectsError({
|
||||||
code: 'ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK',
|
code: 'ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK',
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Flags: --experimental-modules
|
// Flags: --experimental-modules
|
||||||
/* eslint-disable node-core/required-modules */
|
import '../common';
|
||||||
import common from '../common/index.js';
|
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
|
|
||||||
async function doTest() {
|
async function doTest() {
|
||||||
@ -12,5 +11,4 @@ async function doTest() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
doTest();
|
doTest();
|
||||||
|
@ -9,8 +9,6 @@ const net = require('net');
|
|||||||
let running = false;
|
let running = false;
|
||||||
const queue = [];
|
const queue = [];
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const dnsPromises = dns.promises;
|
const dnsPromises = dns.promises;
|
||||||
const isIPv4 = net.isIPv4;
|
const isIPv4 = net.isIPv4;
|
||||||
const isIPv6 = net.isIPv6;
|
const isIPv6 = net.isIPv6;
|
||||||
|
@ -7,8 +7,6 @@ const net = require('net');
|
|||||||
const util = require('util');
|
const util = require('util');
|
||||||
const isIPv4 = net.isIPv4;
|
const isIPv4 = net.isIPv4;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const dnsPromises = dns.promises;
|
const dnsPromises = dns.promises;
|
||||||
let running = false;
|
let running = false;
|
||||||
const queue = [];
|
const queue = [];
|
||||||
|
@ -4,8 +4,6 @@ const { addresses } = require('../common/internet');
|
|||||||
if (!common.hasIPv6)
|
if (!common.hasIPv6)
|
||||||
common.skip('this test, no IPv6 support');
|
common.skip('this test, no IPv6 support');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
const dnsPromises = dns.promises;
|
const dnsPromises = dns.promises;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
(async function() {
|
(async function() {
|
||||||
const result = await dnsPromises.resolveTxt('www.microsoft.com');
|
const result = await dnsPromises.resolveTxt('www.microsoft.com');
|
||||||
assert.strictEqual(result.length, 0);
|
assert.strictEqual(result.length, 0);
|
||||||
|
@ -30,8 +30,6 @@ const isIPv6 = net.isIPv6;
|
|||||||
const util = require('util');
|
const util = require('util');
|
||||||
const dnsPromises = dns.promises;
|
const dnsPromises = dns.promises;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
let expected = 0;
|
let expected = 0;
|
||||||
let completed = 0;
|
let completed = 0;
|
||||||
let running = false;
|
let running = false;
|
||||||
|
@ -23,8 +23,6 @@ if (process.config.variables.v8_enable_inspector === 0) {
|
|||||||
const cluster = require('cluster');
|
const cluster = require('cluster');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const ports = [process.debugPort];
|
const ports = [process.debugPort];
|
||||||
const clashPort = process.debugPort + 2;
|
const clashPort = process.debugPort + 2;
|
||||||
function serialFork() {
|
function serialFork() {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// Flags: --trace-warnings
|
// Flags: --trace-warnings
|
||||||
'use strict';
|
'use strict';
|
||||||
require('../common');
|
const common = require('../common');
|
||||||
|
common.disableCrashOnUnhandledRejection();
|
||||||
const p = Promise.reject(new Error('This was rejected'));
|
const p = Promise.reject(new Error('This was rejected'));
|
||||||
setImmediate(() => p.catch(() => {}));
|
setImmediate(() => p.catch(() => {}));
|
||||||
|
@ -5,8 +5,6 @@ const assert = require('assert');
|
|||||||
// Test assert.rejects() and assert.doesNotReject() by checking their
|
// Test assert.rejects() and assert.doesNotReject() by checking their
|
||||||
// expected output and by verifying that they do not work sync
|
// 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.
|
// Run all tests in parallel and check their outcome at the end.
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const async_hooks = require('async_hooks');
|
const async_hooks = require('async_hooks');
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
if (!common.isMainThread)
|
if (!common.isMainThread)
|
||||||
common.skip('Worker bootstrapping works differently -> different AsyncWraps');
|
common.skip('Worker bootstrapping works differently -> different AsyncWraps');
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const async_hooks = require('async_hooks');
|
const async_hooks = require('async_hooks');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
Promise.resolve(1).then(common.mustCall(() => {
|
Promise.resolve(1).then(common.mustCall(() => {
|
||||||
async_hooks.createHook({
|
async_hooks.createHook({
|
||||||
init: common.mustCall(),
|
init: common.mustCall(),
|
||||||
|
@ -8,8 +8,6 @@ let p_resource = null;
|
|||||||
let p_er = null;
|
let p_er = null;
|
||||||
let p_inits = 0;
|
let p_inits = 0;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
// Not useful to place common.mustCall() around 'exit' event b/c it won't be
|
// Not useful to place common.mustCall() around 'exit' event b/c it won't be
|
||||||
// able to check it anyway.
|
// able to check it anyway.
|
||||||
process.on('exit', (code) => {
|
process.on('exit', (code) => {
|
||||||
|
@ -6,8 +6,6 @@ const async_hooks = require('async_hooks');
|
|||||||
if (!common.isMainThread)
|
if (!common.isMainThread)
|
||||||
common.skip('Worker bootstrapping works differently -> different async IDs');
|
common.skip('Worker bootstrapping works differently -> different async IDs');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const promiseAsyncIds = [];
|
const promiseAsyncIds = [];
|
||||||
|
|
||||||
async_hooks.createHook({
|
async_hooks.createHook({
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
if (process.argv[2] === 'async') {
|
if (process.argv[2] === 'async') {
|
||||||
|
common.disableCrashOnUnhandledRejection();
|
||||||
async function fn() {
|
async function fn() {
|
||||||
fn();
|
fn();
|
||||||
throw new Error();
|
throw new Error();
|
||||||
|
@ -12,8 +12,6 @@ const async_hooks = require('async_hooks');
|
|||||||
|
|
||||||
const seenEvents = [];
|
const seenEvents = [];
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const p = new Promise((resolve) => resolve(1));
|
const p = new Promise((resolve) => resolve(1));
|
||||||
p.then(() => seenEvents.push('then'));
|
p.then(() => seenEvents.push('then'));
|
||||||
|
|
||||||
|
@ -23,8 +23,6 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
const dnsPromises = dns.promises;
|
const dnsPromises = dns.promises;
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@ const assert = require('assert');
|
|||||||
const child_process = require('child_process');
|
const child_process = require('child_process');
|
||||||
const { promisify } = require('util');
|
const { promisify } = require('util');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const exec = promisify(child_process.exec);
|
const exec = promisify(child_process.exec);
|
||||||
const execFile = promisify(child_process.execFile);
|
const execFile = promisify(child_process.execFile);
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ const cares = process.binding('cares_wrap');
|
|||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
const dnsPromises = dns.promises;
|
const dnsPromises = dns.promises;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
// Stub `getaddrinfo` to *always* error.
|
// Stub `getaddrinfo` to *always* error.
|
||||||
cares.getaddrinfo = () => process.binding('uv').UV_ENOENT;
|
cares.getaddrinfo = () => process.binding('uv').UV_ENOENT;
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@ const assert = require('assert');
|
|||||||
|
|
||||||
const dnsPromises = require('dns').promises;
|
const dnsPromises = require('dns').promises;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
// Error when rrtype is invalid.
|
// Error when rrtype is invalid.
|
||||||
{
|
{
|
||||||
const rrtype = 'DUMMY';
|
const rrtype = 'DUMMY';
|
||||||
|
@ -6,8 +6,6 @@ const assert = require('assert');
|
|||||||
const dgram = require('dgram');
|
const dgram = require('dgram');
|
||||||
const dnsPromises = dns.promises;
|
const dnsPromises = dns.promises;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const server = dgram.createSocket('udp4');
|
const server = dgram.createSocket('udp4');
|
||||||
|
|
||||||
server.on('message', common.mustCall((msg, { address, port }) => {
|
server.on('message', common.mustCall((msg, { address, port }) => {
|
||||||
|
@ -6,8 +6,6 @@ const assert = require('assert');
|
|||||||
const dgram = require('dgram');
|
const dgram = require('dgram');
|
||||||
const dnsPromises = dns.promises;
|
const dnsPromises = dns.promises;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const answers = [
|
const answers = [
|
||||||
{ type: 'A', address: '1.2.3.4', ttl: 123 },
|
{ type: 'A', address: '1.2.3.4', ttl: 123 },
|
||||||
{ type: 'AAAA', address: '::42', ttl: 123 },
|
{ type: 'AAAA', address: '::42', ttl: 123 },
|
||||||
|
@ -29,8 +29,6 @@ const common = require('../common');
|
|||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
const dnsPromises = dns.promises;
|
const dnsPromises = dns.promises;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
common.expectsError(
|
common.expectsError(
|
||||||
() => dnsPromises.resolveNs([]), // bad name
|
() => dnsPromises.resolveNs([]), // bad name
|
||||||
{
|
{
|
||||||
|
@ -26,8 +26,6 @@ const assert = require('assert');
|
|||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
const dnsPromises = dns.promises;
|
const dnsPromises = dns.promises;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const existing = dns.getServers();
|
const existing = dns.getServers();
|
||||||
assert(existing.length > 0);
|
assert(existing.length > 0);
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ const domain = require('domain');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const vm = require('vm');
|
const vm = require('vm');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const d = domain.create();
|
const d = domain.create();
|
||||||
|
|
||||||
|
@ -7,8 +7,6 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { promises } = fs;
|
const { promises } = fs;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
// Validate the path argument.
|
// Validate the path argument.
|
||||||
[false, 1, {}, [], null, undefined].forEach((i) => {
|
[false, 1, {}, [], null, undefined].forEach((i) => {
|
||||||
const err = { type: TypeError, code: 'ERR_INVALID_ARG_TYPE' };
|
const err = { type: TypeError, code: 'ERR_INVALID_ARG_TYPE' };
|
||||||
|
@ -13,7 +13,6 @@ const assert = require('assert');
|
|||||||
const tmpDir = tmpdir.path;
|
const tmpDir = tmpdir.path;
|
||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function validateAppendBuffer() {
|
async function validateAppendBuffer() {
|
||||||
const filePath = path.resolve(tmpDir, 'tmp-append-file-buffer.txt');
|
const filePath = path.resolve(tmpDir, 'tmp-append-file-buffer.txt');
|
||||||
|
@ -13,7 +13,6 @@ const assert = require('assert');
|
|||||||
const tmpDir = tmpdir.path;
|
const tmpDir = tmpdir.path;
|
||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function validateFilePermission() {
|
async function validateFilePermission() {
|
||||||
const filePath = path.resolve(tmpDir, 'tmp-chmod.txt');
|
const filePath = path.resolve(tmpDir, 'tmp-chmod.txt');
|
||||||
|
@ -14,7 +14,6 @@ const assert = require('assert');
|
|||||||
const tmpDir = tmpdir.path;
|
const tmpDir = tmpdir.path;
|
||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function validateRead() {
|
async function validateRead() {
|
||||||
const filePath = path.resolve(tmpDir, 'tmp-read-file.txt');
|
const filePath = path.resolve(tmpDir, 'tmp-read-file.txt');
|
||||||
|
@ -13,7 +13,6 @@ const assert = require('assert');
|
|||||||
const tmpDir = tmpdir.path;
|
const tmpDir = tmpdir.path;
|
||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function validateReadFile() {
|
async function validateReadFile() {
|
||||||
const filePath = path.resolve(tmpDir, 'tmp-read-file.txt');
|
const filePath = path.resolve(tmpDir, 'tmp-read-file.txt');
|
||||||
|
@ -11,7 +11,6 @@ const tmpdir = require('../common/tmpdir');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function validateStat() {
|
async function validateStat() {
|
||||||
const filePath = path.resolve(tmpdir.path, 'tmp-read-file.txt');
|
const filePath = path.resolve(tmpdir.path, 'tmp-read-file.txt');
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
const tmpdir = require('../common/tmpdir');
|
const tmpdir = require('../common/tmpdir');
|
||||||
@ -7,8 +7,6 @@ const tmpdir = require('../common/tmpdir');
|
|||||||
const { access, copyFile, open } = require('fs').promises;
|
const { access, copyFile, open } = require('fs').promises;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function validateSync() {
|
async function validateSync() {
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
const dest = path.resolve(tmpdir.path, 'baz.js');
|
const dest = path.resolve(tmpdir.path, 'baz.js');
|
||||||
|
@ -7,7 +7,6 @@ const { open, readFile } = require('fs').promises;
|
|||||||
const tmpdir = require('../common/tmpdir');
|
const tmpdir = require('../common/tmpdir');
|
||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function validateTruncate() {
|
async function validateTruncate() {
|
||||||
const text = 'Hello world';
|
const text = 'Hello world';
|
||||||
|
@ -13,7 +13,6 @@ const assert = require('assert');
|
|||||||
const tmpDir = tmpdir.path;
|
const tmpDir = tmpdir.path;
|
||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function validateWrite() {
|
async function validateWrite() {
|
||||||
const filePathForHandle = path.resolve(tmpDir, 'tmp-write.txt');
|
const filePathForHandle = path.resolve(tmpDir, 'tmp-write.txt');
|
||||||
|
@ -13,7 +13,6 @@ const assert = require('assert');
|
|||||||
const tmpDir = tmpdir.path;
|
const tmpDir = tmpdir.path;
|
||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function validateWriteFile() {
|
async function validateWriteFile() {
|
||||||
const filePathForHandle = path.resolve(tmpDir, 'tmp-write-file2.txt');
|
const filePathForHandle = path.resolve(tmpDir, 'tmp-write-file2.txt');
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { promises: fs } = require('fs');
|
const { promises: fs } = require('fs');
|
||||||
@ -7,8 +7,6 @@ const fixtures = require('../common/fixtures');
|
|||||||
|
|
||||||
const fn = fixtures.path('empty.txt');
|
const fn = fixtures.path('empty.txt');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
fs.readFile(fn)
|
fs.readFile(fn)
|
||||||
.then(assert.ok);
|
.then(assert.ok);
|
||||||
|
|
||||||
|
@ -10,8 +10,6 @@ tmpdir.refresh();
|
|||||||
|
|
||||||
const fn = path.join(tmpdir.path, 'large-file');
|
const fn = path.join(tmpdir.path, 'large-file');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function validateReadFile() {
|
async function validateReadFile() {
|
||||||
// Creating large buffer with random content
|
// Creating large buffer with random content
|
||||||
const buffer = Buffer.from(
|
const buffer = Buffer.from(
|
||||||
|
@ -10,8 +10,6 @@ const tmpDir = tmpdir.path;
|
|||||||
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const dest = path.resolve(tmpDir, 'tmp.txt');
|
const dest = path.resolve(tmpDir, 'tmp.txt');
|
||||||
const buffer = Buffer.from('abc'.repeat(1000));
|
const buffer = Buffer.from('abc'.repeat(1000));
|
||||||
const buffer2 = Buffer.from('xyz'.repeat(1000));
|
const buffer2 = Buffer.from('xyz'.repeat(1000));
|
||||||
|
@ -32,16 +32,13 @@ const {
|
|||||||
|
|
||||||
const tmpDir = tmpdir.path;
|
const tmpDir = tmpdir.path;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
// fs.promises should not be enumerable as long as it causes a warning to be
|
// fs.promises should not be enumerable as long as it causes a warning to be
|
||||||
// emitted.
|
// emitted.
|
||||||
assert.strictEqual(Object.keys(fs).includes('promises'), false);
|
assert.strictEqual(Object.keys(fs).includes('promises'), false);
|
||||||
|
|
||||||
{
|
{
|
||||||
access(__filename, 'r')
|
access(__filename, 'r')
|
||||||
.then(common.mustCall())
|
.then(common.mustCall());
|
||||||
.catch(common.mustNotCall());
|
|
||||||
|
|
||||||
access('this file does not exist', 'r')
|
access('this file does not exist', 'r')
|
||||||
.then(common.mustNotCall())
|
.then(common.mustNotCall())
|
||||||
|
@ -5,8 +5,6 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { promisify } = require('util');
|
const { promisify } = require('util');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const read = promisify(fs.read);
|
const read = promisify(fs.read);
|
||||||
const write = promisify(fs.write);
|
const write = promisify(fs.write);
|
||||||
const exists = promisify(fs.exists);
|
const exists = promisify(fs.exists);
|
||||||
|
@ -8,7 +8,6 @@ const path = require('path');
|
|||||||
const tmpdir = require('../common/tmpdir');
|
const tmpdir = require('../common/tmpdir');
|
||||||
const { isDate } = require('util').types;
|
const { isDate } = require('util').types;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
tmpdir.refresh();
|
tmpdir.refresh();
|
||||||
|
|
||||||
const fn = path.join(tmpdir.path, 'test-file');
|
const fn = path.join(tmpdir.path, 'test-file');
|
||||||
|
@ -24,7 +24,6 @@ const common = require('../common');
|
|||||||
const Countdown = require('../common/countdown');
|
const Countdown = require('../common/countdown');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const N = 4;
|
const N = 4;
|
||||||
const M = 4;
|
const M = 4;
|
||||||
|
@ -9,8 +9,6 @@ const assert = require('assert');
|
|||||||
const http2 = require('http2');
|
const http2 = require('http2');
|
||||||
const makeDuplexPair = require('../common/duplexpair');
|
const makeDuplexPair = require('../common/duplexpair');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
let req;
|
let req;
|
||||||
const server = http2.createServer();
|
const server = http2.createServer();
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto)
|
||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
@ -18,7 +17,6 @@ server.listen(0, common.mustCall(() => {
|
|||||||
const connect = util.promisify(http2.connect);
|
const connect = util.promisify(http2.connect);
|
||||||
|
|
||||||
connect(`http://localhost:${server.address().port}`)
|
connect(`http://localhost:${server.address().port}`)
|
||||||
.catch(common.mustNotCall())
|
|
||||||
.then(common.mustCall((client) => {
|
.then(common.mustCall((client) => {
|
||||||
assert(client);
|
assert(client);
|
||||||
const req = client.request();
|
const req = client.request();
|
||||||
|
@ -10,7 +10,6 @@ if (!common.hasCrypto)
|
|||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const h2 = require('http2');
|
const h2 = require('http2');
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
// Given a list of buffers and an initial window size, have a server write
|
// 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
|
// each buffer to the HTTP2 Writable stream, and let the client verify that
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
common.skipIf32Bits();
|
common.skipIf32Bits();
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
const { NodeInstance } = require('../common/inspector-helper.js');
|
const { NodeInstance } = require('../common/inspector-helper.js');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
|
@ -110,6 +110,4 @@ async function runTest() {
|
|||||||
assert.strictEqual((await child.expectShutdown()).exitCode, 55);
|
assert.strictEqual((await child.expectShutdown()).exitCode, 55);
|
||||||
}
|
}
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
runTest();
|
runTest();
|
||||||
|
@ -54,8 +54,6 @@ async function test() {
|
|||||||
console.log('Sessions were disconnected');
|
console.log('Sessions were disconnected');
|
||||||
}
|
}
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const interval = setInterval(() => {}, 1000);
|
const interval = setInterval(() => {}, 1000);
|
||||||
test().then(() => {
|
test().then(() => {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
|
@ -70,6 +70,4 @@ async function runTest() {
|
|||||||
return child.expectShutdown();
|
return child.expectShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
runTest();
|
runTest();
|
||||||
|
@ -7,8 +7,6 @@ common.skipIfInspectorDisabled();
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { NodeInstance } = require('../common/inspector-helper.js');
|
const { NodeInstance } = require('../common/inspector-helper.js');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function test() {
|
async function test() {
|
||||||
const madeUpHost = '111.111.111.111:11111';
|
const madeUpHost = '111.111.111.111:11111';
|
||||||
const child = new NodeInstance(undefined, 'var a = 1');
|
const child = new NodeInstance(undefined, 'var a = 1');
|
||||||
|
@ -65,6 +65,4 @@ async function test() {
|
|||||||
console.log('Success');
|
console.log('Success');
|
||||||
}
|
}
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
test();
|
test();
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
// Flags: --expose-internals
|
// Flags: --expose-internals
|
||||||
|
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const { ModuleWrap } = require('internal/test/binding');
|
const { ModuleWrap } = require('internal/test/binding');
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
// Requiring the domain module here changes the function that is used by node to
|
// Requiring the domain module here changes the function that is used by node to
|
||||||
@ -30,8 +30,6 @@ const assert = require('assert');
|
|||||||
// removed.
|
// removed.
|
||||||
require('domain');
|
require('domain');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const implementations = [
|
const implementations = [
|
||||||
function(fn) {
|
function(fn) {
|
||||||
Promise.resolve().then(fn);
|
Promise.resolve().then(fn);
|
||||||
|
@ -20,11 +20,9 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const implementations = [
|
const implementations = [
|
||||||
function(fn) {
|
function(fn) {
|
||||||
Promise.resolve().then(fn);
|
Promise.resolve().then(fn);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
// Requiring the domain module here changes the function that is used by node to
|
// Requiring the domain module here changes the function that is used by node to
|
||||||
@ -30,8 +30,6 @@ const assert = require('assert');
|
|||||||
// removed.
|
// removed.
|
||||||
require('domain');
|
require('domain');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
function enqueueMicrotask(fn) {
|
function enqueueMicrotask(fn) {
|
||||||
Promise.resolve().then(fn);
|
Promise.resolve().then(fn);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
// Requiring the domain module here changes the function that is used by node to
|
// Requiring the domain module here changes the function that is used by node to
|
||||||
@ -30,8 +30,6 @@ const assert = require('assert');
|
|||||||
// removed.
|
// removed.
|
||||||
require('domain');
|
require('domain');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
function enqueueMicrotask(fn) {
|
function enqueueMicrotask(fn) {
|
||||||
Promise.resolve().then(fn);
|
Promise.resolve().then(fn);
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,9 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
function enqueueMicrotask(fn) {
|
function enqueueMicrotask(fn) {
|
||||||
Promise.resolve().then(fn);
|
Promise.resolve().then(fn);
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,9 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
function enqueueMicrotask(fn) {
|
function enqueueMicrotask(fn) {
|
||||||
Promise.resolve().then(fn);
|
Promise.resolve().then(fn);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
// Sets the server's maxConnections property to 1.
|
// Sets the server's maxConnections property to 1.
|
||||||
// Open 2 connections (connection 0 and connection 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.
|
// ...but that only connections 0 and 2 were successful.
|
||||||
assert.deepStrictEqual(received, ['0', '2']);
|
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';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
|
common.disableCrashOnUnhandledRejection();
|
||||||
|
|
||||||
const expectedDeprecationWarning = ['Unhandled promise rejections are ' +
|
const expectedDeprecationWarning = ['Unhandled promise rejections are ' +
|
||||||
'deprecated. In the future, promise ' +
|
'deprecated. In the future, promise ' +
|
||||||
'rejections that are not handled will ' +
|
'rejections that are not handled will ' +
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const domain = require('domain');
|
const domain = require('domain');
|
||||||
|
|
||||||
|
common.disableCrashOnUnhandledRejection();
|
||||||
|
|
||||||
const asyncTest = (function() {
|
const asyncTest = (function() {
|
||||||
let asyncTestsEnabled = false;
|
let asyncTestsEnabled = false;
|
||||||
let asyncTestLastCheck;
|
let asyncTestLastCheck;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
|
common.disableCrashOnUnhandledRejection();
|
||||||
|
|
||||||
const expectedValueWarning = ['Symbol()', common.noWarnCode];
|
const expectedValueWarning = ['Symbol()', common.noWarnCode];
|
||||||
const expectedDeprecationWarning = ['Unhandled promise rejections are ' +
|
const expectedDeprecationWarning = ['Unhandled promise rejections are ' +
|
||||||
'deprecated. In the future, promise ' +
|
'deprecated. In the future, promise ' +
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
|
common.disableCrashOnUnhandledRejection();
|
||||||
|
|
||||||
let b = 0;
|
let b = 0;
|
||||||
|
|
||||||
process.on('warning', common.mustCall((warning) => {
|
process.on('warning', common.mustCall((warning) => {
|
||||||
|
@ -4,8 +4,6 @@ const fixtures = require('../common/fixtures');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const command = `.load ${fixtures.path('repl-load-multiline.js')}`;
|
const command = `.load ${fixtures.path('repl-load-multiline.js')}`;
|
||||||
const terminalCode = '\u001b[1G\u001b[0J \u001b[1G';
|
const terminalCode = '\u001b[1G\u001b[0J \u001b[1G';
|
||||||
const terminalCodeRegex = new RegExp(terminalCode.replace(/\[/g, '\\['), 'g');
|
const terminalCodeRegex = new RegExp(terminalCode.replace(/\[/g, '\\['), 'g');
|
||||||
|
@ -5,8 +5,6 @@ const assert = require('assert');
|
|||||||
const { stripVTControlCharacters } = require('internal/readline');
|
const { stripVTControlCharacters } = require('internal/readline');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
// Flags: --expose-internals --experimental-repl-await
|
// Flags: --expose-internals --experimental-repl-await
|
||||||
|
|
||||||
const PROMPT = 'await repl > ';
|
const PROMPT = 'await repl > ';
|
||||||
|
@ -26,8 +26,6 @@ const assert = require('assert');
|
|||||||
const net = require('net');
|
const net = require('net');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const message = 'Read, Eval, Print Loop';
|
const message = 'Read, Eval, Print Loop';
|
||||||
const prompt_unix = 'node via Unix socket> ';
|
const prompt_unix = 'node via Unix socket> ';
|
||||||
const prompt_tcp = 'node via TCP socket> ';
|
const prompt_tcp = 'node via TCP socket> ';
|
||||||
|
@ -6,8 +6,6 @@ const assert = require('assert');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { promisify } = require('util');
|
const { promisify } = require('util');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const rs = new Readable({
|
const rs = new Readable({
|
||||||
read() {}
|
read() {}
|
||||||
|
@ -9,8 +9,6 @@ const http = require('http');
|
|||||||
const http2 = require('http2');
|
const http2 = require('http2');
|
||||||
const { promisify } = require('util');
|
const { promisify } = require('util');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
let finished = false;
|
let finished = false;
|
||||||
const processed = [];
|
const processed = [];
|
||||||
|
@ -4,8 +4,6 @@ const common = require('../common');
|
|||||||
const { Readable } = require('stream');
|
const { Readable } = require('stream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function tests() {
|
async function tests() {
|
||||||
await (async function() {
|
await (async function() {
|
||||||
console.log('read without for..await');
|
console.log('read without for..await');
|
||||||
|
@ -6,8 +6,6 @@ const { promisify } = require('util');
|
|||||||
|
|
||||||
/* eslint-disable no-restricted-syntax */
|
/* eslint-disable no-restricted-syntax */
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const setTimeout = promisify(timers.setTimeout);
|
const setTimeout = promisify(timers.setTimeout);
|
||||||
const setImmediate = promisify(timers.setImmediate);
|
const setImmediate = promisify(timers.setImmediate);
|
||||||
|
|
||||||
|
@ -2,11 +2,9 @@
|
|||||||
|
|
||||||
// Flags: --experimental-vm-modules
|
// Flags: --experimental-vm-modules
|
||||||
|
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const { Module } = require('vm');
|
const { Module } = require('vm');
|
||||||
const { inspect } = require('util');
|
const { inspect } = require('util');
|
||||||
|
|
||||||
|
@ -7,8 +7,6 @@ const vm = require('vm');
|
|||||||
const { promisify } = require('util');
|
const { promisify } = require('util');
|
||||||
const { customPromisifyArgs } = require('internal/util');
|
const { customPromisifyArgs } = require('internal/util');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const stat = promisify(fs.stat);
|
const stat = promisify(fs.stat);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
// Flags: --harmony-bigint --experimental-vm-modules
|
// Flags: --harmony-bigint --experimental-vm-modules
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { types, inspect } = require('util');
|
const { types, inspect } = require('util');
|
||||||
const vm = require('vm');
|
const vm = require('vm');
|
||||||
const { JSStream } = process.binding('js_stream');
|
const { JSStream } = process.binding('js_stream');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const external = (new JSStream())._externalStream;
|
const external = (new JSStream())._externalStream;
|
||||||
const wasmBuffer = fixtures.readSync('test.wasm');
|
const wasmBuffer = fixtures.readSync('test.wasm');
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { Module, createContext } = require('vm');
|
const { Module, createContext } = require('vm');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
(async function test1() {
|
(async function test1() {
|
||||||
const context = createContext({
|
const context = createContext({
|
||||||
foo: 'bar',
|
foo: 'bar',
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
// Flags: --experimental-vm-modules --experimental-modules --harmony-dynamic-import
|
// Flags: --experimental-vm-modules --experimental-modules --harmony-dynamic-import
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { Module, createContext } = require('vm');
|
const { Module, createContext } = require('vm');
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
// Flags: --experimental-vm-modules
|
// Flags: --experimental-vm-modules
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { Module } = require('vm');
|
const { Module } = require('vm');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function testBasic() {
|
async function testBasic() {
|
||||||
const m = new Module('import.meta;', {
|
const m = new Module('import.meta;', {
|
||||||
initializeImportMeta: common.mustCall((meta, module) => {
|
initializeImportMeta: common.mustCall((meta, module) => {
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
// Flags: --experimental-vm-modules
|
// Flags: --experimental-vm-modules
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { URL } = require('url');
|
const { URL } = require('url');
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
// Flags: --experimental-vm-modules
|
// Flags: --experimental-vm-modules
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
const buffer = fixtures.readSync('test.wasm');
|
const buffer = fixtures.readSync('test.wasm');
|
||||||
|
|
||||||
assert.ok(WebAssembly.validate(buffer), 'Buffer should be valid WebAssembly');
|
assert.ok(WebAssembly.validate(buffer), 'Buffer should be valid WebAssembly');
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
const { inspect, promisify } = require('util');
|
const { inspect, promisify } = require('util');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const emptyBuffer = Buffer.alloc(0);
|
const emptyBuffer = Buffer.alloc(0);
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
(async function() {
|
(async function() {
|
||||||
for (const [ compress, decompress, method ] of [
|
for (const [ compress, decompress, method ] of [
|
||||||
[ zlib.deflateRawSync, zlib.inflateRawSync, 'raw sync' ],
|
[ zlib.deflateRawSync, zlib.inflateRawSync, 'raw sync' ],
|
||||||
|
@ -8,8 +8,6 @@ const {
|
|||||||
Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH
|
Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH
|
||||||
} = zlib.constants;
|
} = zlib.constants;
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
async function getOutput(...sequenceOfFlushes) {
|
async function getOutput(...sequenceOfFlushes) {
|
||||||
const zipper = zlib.createGzip({ highWaterMark: 16384 });
|
const zipper = zlib.createGzip({ highWaterMark: 16384 });
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@ const fixtures = require('../common/fixtures');
|
|||||||
const tmpdir = require('../common/tmpdir');
|
const tmpdir = require('../common/tmpdir');
|
||||||
const { getSystemErrorName } = require('util');
|
const { getSystemErrorName } = require('util');
|
||||||
|
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
|
|
||||||
// Make sure that all Providers are tested.
|
// Make sure that all Providers are tested.
|
||||||
{
|
{
|
||||||
const hooks = require('async_hooks').createHook({
|
const hooks = require('async_hooks').createHook({
|
||||||
@ -198,7 +196,7 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
|
|||||||
testInitialized(fd, 'FileHandle');
|
testInitialized(fd, 'FileHandle');
|
||||||
await fd.close();
|
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?';
|
const eyecatcher = 'nou, houdoe he?';
|
||||||
|
|
||||||
if (process.argv[2] === 'child') {
|
if (process.argv[2] === 'child') {
|
||||||
|
common.disableCrashOnUnhandledRejection();
|
||||||
const { Session } = require('inspector');
|
const { Session } = require('inspector');
|
||||||
const { promisify } = require('util');
|
const { promisify } = require('util');
|
||||||
const { registerAsyncHook } = process.binding('inspector');
|
const { registerAsyncHook } = process.binding('inspector');
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
common.skipIf32Bits();
|
common.skipIf32Bits();
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
const { NodeInstance } = require('../common/inspector-helper.js');
|
const { NodeInstance } = require('../common/inspector-helper.js');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
common.skipIf32Bits();
|
common.skipIf32Bits();
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
const { NodeInstance } = require('../common/inspector-helper.js');
|
const { NodeInstance } = require('../common/inspector-helper.js');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
common.skipIfInspectorDisabled();
|
common.skipIfInspectorDisabled();
|
||||||
common.skipIf32Bits();
|
common.skipIf32Bits();
|
||||||
common.crashOnUnhandledRejection();
|
|
||||||
const { NodeInstance } = require('../common/inspector-helper');
|
const { NodeInstance } = require('../common/inspector-helper');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user