mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
errors: improve performance of instantiation
PR-URL: https://github.com/nodejs/node/pull/49654 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Raz Luvaton <rluvaton@gmail.com>
This commit is contained in:
parent
7ca1228be8
commit
c71e548b65
66
benchmark/error/node-error-instantiation.js
Normal file
66
benchmark/error/node-error-instantiation.js
Normal file
@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e6],
|
||||
code: [
|
||||
'built-in',
|
||||
'ERR_HTTP2_STREAM_SELF_DEPENDENCY',
|
||||
'ERR_INVALID_STATE',
|
||||
'ERR_INVALID_URL',
|
||||
],
|
||||
stackTraceLimit: [0, 10],
|
||||
}, {
|
||||
flags: ['--expose-internals'],
|
||||
});
|
||||
|
||||
function getErrorFactory(code) {
|
||||
const {
|
||||
ERR_HTTP2_STREAM_SELF_DEPENDENCY,
|
||||
ERR_INVALID_STATE,
|
||||
ERR_INVALID_URL,
|
||||
} = require('internal/errors').codes;
|
||||
|
||||
switch (code) {
|
||||
case 'built-in':
|
||||
return (n) => new Error();
|
||||
case 'ERR_HTTP2_STREAM_SELF_DEPENDENCY':
|
||||
return (n) => new ERR_HTTP2_STREAM_SELF_DEPENDENCY();
|
||||
case 'ERR_INVALID_STATE':
|
||||
return (n) => new ERR_INVALID_STATE(n + '');
|
||||
case 'ERR_INVALID_URL':
|
||||
return (n) => new ERR_INVALID_URL({ input: n + '' });
|
||||
default:
|
||||
throw new Error(`${code} not supported`);
|
||||
}
|
||||
}
|
||||
|
||||
function main({ n, code, stackTraceLimit }) {
|
||||
const getError = getErrorFactory(code);
|
||||
|
||||
Error.stackTraceLimit = stackTraceLimit;
|
||||
|
||||
// Warm up.
|
||||
const length = 1024;
|
||||
const array = [];
|
||||
for (let i = 0; i < length; ++i) {
|
||||
array.push(getError(i));
|
||||
}
|
||||
|
||||
bench.start();
|
||||
|
||||
for (let i = 0; i < n; ++i) {
|
||||
const index = i % length;
|
||||
array[index] = getError(index);
|
||||
}
|
||||
|
||||
bench.end(n);
|
||||
|
||||
// Verify the entries to prevent dead code elimination from making
|
||||
// the benchmark invalid.
|
||||
for (let i = 0; i < length; ++i) {
|
||||
assert.strictEqual(typeof array[i], 'object');
|
||||
}
|
||||
}
|
62
benchmark/error/node-error-stack.js
Normal file
62
benchmark/error/node-error-stack.js
Normal file
@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e6],
|
||||
code: [
|
||||
'built-in',
|
||||
'ERR_HTTP2_STREAM_SELF_DEPENDENCY',
|
||||
'ERR_INVALID_STATE',
|
||||
],
|
||||
stackTraceLimit: [0, 10],
|
||||
}, {
|
||||
flags: ['--expose-internals'],
|
||||
});
|
||||
|
||||
function getErrorStackFactory(code) {
|
||||
const {
|
||||
ERR_INVALID_STATE,
|
||||
ERR_HTTP2_STREAM_SELF_DEPENDENCY,
|
||||
} = require('internal/errors').codes;
|
||||
|
||||
switch (code) {
|
||||
case 'built-in':
|
||||
return (n) => new Error().stack;
|
||||
case 'ERR_HTTP2_STREAM_SELF_DEPENDENCY':
|
||||
return (n) => new ERR_HTTP2_STREAM_SELF_DEPENDENCY().stack;
|
||||
case 'ERR_INVALID_STATE':
|
||||
return (n) => new ERR_INVALID_STATE(n + '').stack;
|
||||
default:
|
||||
throw new Error(`${code} not supported`);
|
||||
}
|
||||
}
|
||||
|
||||
function main({ n, code, stackTraceLimit }) {
|
||||
const getStack = getErrorStackFactory(code);
|
||||
|
||||
Error.stackTraceLimit = stackTraceLimit;
|
||||
|
||||
// Warm up.
|
||||
const length = 1024;
|
||||
const array = [];
|
||||
for (let i = 0; i < length; ++i) {
|
||||
array.push(getStack(i));
|
||||
}
|
||||
|
||||
bench.start();
|
||||
|
||||
for (let i = 0; i < n; ++i) {
|
||||
const index = i % length;
|
||||
array[index] = getStack(index);
|
||||
}
|
||||
|
||||
bench.end(n);
|
||||
|
||||
// Verify the entries to prevent dead code elimination from making
|
||||
// the benchmark invalid.
|
||||
for (let i = 0; i < length; ++i) {
|
||||
assert.strictEqual(typeof array[i], 'string');
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
n: [1e7],
|
||||
}, {
|
||||
flags: ['--expose-internals'],
|
||||
});
|
||||
|
||||
function main({ n }) {
|
||||
const {
|
||||
codes: {
|
||||
ERR_INVALID_STATE,
|
||||
},
|
||||
} = require('internal/errors');
|
||||
bench.start();
|
||||
for (let i = 0; i < n; ++i)
|
||||
new ERR_INVALID_STATE.TypeError('test');
|
||||
bench.end(n);
|
||||
}
|
@ -57,7 +57,7 @@ const validateParameters = hideStackFrames((hash, key, salt, info, length) => {
|
||||
validateInteger(length, 'length', 0, kMaxLength);
|
||||
|
||||
if (info.byteLength > 1024) {
|
||||
throw ERR_OUT_OF_RANGE(
|
||||
throw new ERR_OUT_OF_RANGE(
|
||||
'info',
|
||||
'must not contain more than 1024 bytes',
|
||||
info.byteLength);
|
||||
|
@ -175,9 +175,10 @@ const aggregateErrors = hideStackFrames((errors, message, code) => {
|
||||
return err;
|
||||
});
|
||||
|
||||
const assert = require('internal/assert');
|
||||
|
||||
// Lazily loaded
|
||||
let util;
|
||||
let assert;
|
||||
|
||||
let internalUtil = null;
|
||||
function lazyInternalUtil() {
|
||||
@ -371,42 +372,103 @@ function makeSystemErrorWithCode(key) {
|
||||
}
|
||||
|
||||
function makeNodeErrorWithCode(Base, key) {
|
||||
return function NodeError(...args) {
|
||||
const limit = Error.stackTraceLimit;
|
||||
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
|
||||
const error = new Base();
|
||||
// Reset the limit and setting the name property.
|
||||
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
|
||||
const message = getMessage(key, args, error);
|
||||
ObjectDefineProperties(error, {
|
||||
[kIsNodeError]: {
|
||||
__proto__: null,
|
||||
value: true,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true,
|
||||
},
|
||||
message: {
|
||||
__proto__: null,
|
||||
value: message,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
},
|
||||
toString: {
|
||||
__proto__: null,
|
||||
value() {
|
||||
const msg = messages.get(key);
|
||||
const expectedLength = typeof msg !== 'string' ? -1 : getExpectedArgumentLength(msg);
|
||||
|
||||
switch (expectedLength) {
|
||||
case 0: {
|
||||
class NodeError extends Base {
|
||||
code = key;
|
||||
|
||||
constructor(...args) {
|
||||
assert(
|
||||
args.length === 0,
|
||||
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
|
||||
`match the required ones (${expectedLength}).`,
|
||||
);
|
||||
super(msg);
|
||||
}
|
||||
|
||||
// This is a workaround for wpt tests that expect that the error
|
||||
// constructor has a `name` property of the base class.
|
||||
get ['constructor']() {
|
||||
return Base;
|
||||
}
|
||||
|
||||
get [kIsNodeError]() {
|
||||
return true;
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `${this.name} [${key}]: ${this.message}`;
|
||||
},
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
},
|
||||
});
|
||||
captureLargerStackTrace(error);
|
||||
error.code = key;
|
||||
return error;
|
||||
};
|
||||
}
|
||||
}
|
||||
return NodeError;
|
||||
}
|
||||
case -1: {
|
||||
class NodeError extends Base {
|
||||
code = key;
|
||||
|
||||
constructor(...args) {
|
||||
super();
|
||||
ObjectDefineProperty(this, 'message', {
|
||||
__proto__: null,
|
||||
value: getMessage(key, args, this),
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
|
||||
// This is a workaround for wpt tests that expect that the error
|
||||
// constructor has a `name` property of the base class.
|
||||
get ['constructor']() {
|
||||
return Base;
|
||||
}
|
||||
|
||||
get [kIsNodeError]() {
|
||||
return true;
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `${this.name} [${key}]: ${this.message}`;
|
||||
}
|
||||
}
|
||||
return NodeError;
|
||||
}
|
||||
default: {
|
||||
|
||||
class NodeError extends Base {
|
||||
code = key;
|
||||
|
||||
constructor(...args) {
|
||||
assert(
|
||||
args.length === expectedLength,
|
||||
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
|
||||
`match the required ones (${expectedLength}).`,
|
||||
);
|
||||
|
||||
ArrayPrototypeUnshift(args, msg);
|
||||
super(ReflectApply(lazyInternalUtilInspect().format, null, args));
|
||||
}
|
||||
|
||||
// This is a workaround for wpt tests that expect that the error
|
||||
// constructor has a `name` property of the base class.
|
||||
get ['constructor']() {
|
||||
return Base;
|
||||
}
|
||||
|
||||
get [kIsNodeError]() {
|
||||
return true;
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `${this.name} [${key}]: ${this.message}`;
|
||||
}
|
||||
}
|
||||
return NodeError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -443,11 +505,16 @@ function E(sym, val, def, ...otherClasses) {
|
||||
codes[sym] = def;
|
||||
}
|
||||
|
||||
function getExpectedArgumentLength(msg) {
|
||||
let expectedLength = 0;
|
||||
const regex = /%[dfijoOs]/g;
|
||||
while (RegExpPrototypeExec(regex, msg) !== null) expectedLength++;
|
||||
return expectedLength;
|
||||
}
|
||||
|
||||
function getMessage(key, args, self) {
|
||||
const msg = messages.get(key);
|
||||
|
||||
assert ??= require('internal/assert');
|
||||
|
||||
if (typeof msg === 'function') {
|
||||
assert(
|
||||
msg.length <= args.length, // Default options do not count.
|
||||
@ -457,9 +524,7 @@ function getMessage(key, args, self) {
|
||||
return ReflectApply(msg, self, args);
|
||||
}
|
||||
|
||||
const regex = /%[dfijoOs]/g;
|
||||
let expectedLength = 0;
|
||||
while (RegExpPrototypeExec(regex, msg) !== null) expectedLength++;
|
||||
const expectedLength = getExpectedArgumentLength(msg);
|
||||
assert(
|
||||
expectedLength === args.length,
|
||||
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
|
||||
@ -1476,8 +1541,7 @@ E('ERR_NETWORK_IMPORT_DISALLOWED',
|
||||
"import of '%s' by %s is not supported: %s", Error);
|
||||
E('ERR_NOT_BUILDING_SNAPSHOT',
|
||||
'Operation cannot be invoked when not building startup snapshot', Error);
|
||||
E('ERR_NOT_SUPPORTED_IN_SNAPSHOT',
|
||||
'%s is not supported in startup snapshot', Error);
|
||||
E('ERR_NOT_SUPPORTED_IN_SNAPSHOT', '%s is not supported in startup snapshot', Error);
|
||||
E('ERR_NO_CRYPTO',
|
||||
'Node.js is not compiled with OpenSSL crypto support', Error);
|
||||
E('ERR_NO_ICU',
|
||||
|
@ -143,8 +143,8 @@ function importFd(stream, options) {
|
||||
return options.fd.fd;
|
||||
}
|
||||
|
||||
throw ERR_INVALID_ARG_TYPE('options.fd',
|
||||
['number', 'FileHandle'], options.fd);
|
||||
throw new ERR_INVALID_ARG_TYPE('options.fd',
|
||||
['number', 'FileHandle'], options.fd);
|
||||
}
|
||||
|
||||
function ReadStream(path, options) {
|
||||
|
@ -471,7 +471,7 @@ class Hooks {
|
||||
!isAnyArrayBuffer(source) &&
|
||||
!isArrayBufferView(source)
|
||||
) {
|
||||
throw ERR_INVALID_RETURN_PROPERTY_VALUE(
|
||||
throw new ERR_INVALID_RETURN_PROPERTY_VALUE(
|
||||
'a string, an ArrayBuffer, or a TypedArray',
|
||||
hookErrIdentifier,
|
||||
'source',
|
||||
@ -662,7 +662,7 @@ class HooksProxy {
|
||||
if (status === 'error') {
|
||||
if (body == null || typeof body !== 'object') { throw body; }
|
||||
if (body.serializationFailed || body.serialized == null) {
|
||||
throw ERR_WORKER_UNSERIALIZABLE_ERROR();
|
||||
throw new ERR_WORKER_UNSERIALIZABLE_ERROR();
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
|
@ -847,7 +847,7 @@ class URL {
|
||||
set href(value) {
|
||||
value = `${value}`;
|
||||
const href = bindingUrl.update(this.#context.href, updateActions.kHref, value);
|
||||
if (!href) { throw ERR_INVALID_URL(value); }
|
||||
if (!href) { throw new ERR_INVALID_URL(value); }
|
||||
this.#updateContext(href);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ for (const key of ObjectKeys(streamReturningOperators)) {
|
||||
const op = streamReturningOperators[key];
|
||||
function fn(...args) {
|
||||
if (new.target) {
|
||||
throw ERR_ILLEGAL_CONSTRUCTOR();
|
||||
throw new ERR_ILLEGAL_CONSTRUCTOR();
|
||||
}
|
||||
return Stream.Readable.from(ReflectApply(op, this, args));
|
||||
}
|
||||
@ -82,7 +82,7 @@ for (const key of ObjectKeys(promiseReturningOperators)) {
|
||||
const op = promiseReturningOperators[key];
|
||||
function fn(...args) {
|
||||
if (new.target) {
|
||||
throw ERR_ILLEGAL_CONSTRUCTOR();
|
||||
throw new ERR_ILLEGAL_CONSTRUCTOR();
|
||||
}
|
||||
return ReflectApply(op, this, args);
|
||||
}
|
||||
|
@ -712,9 +712,8 @@ function expectsError(validator, exact) {
|
||||
assert.fail(`Expected one argument, got ${inspect(args)}`);
|
||||
}
|
||||
const error = args.pop();
|
||||
const descriptor = Object.getOwnPropertyDescriptor(error, 'message');
|
||||
// The error message should be non-enumerable
|
||||
assert.strictEqual(descriptor.enumerable, false);
|
||||
assert.strictEqual(Object.prototype.propertyIsEnumerable.call(error, 'message'), false);
|
||||
|
||||
assert.throws(() => { throw error; }, validator);
|
||||
return true;
|
||||
|
@ -10,6 +10,7 @@
|
||||
<skipped type="todo" message="true"/>
|
||||
<failure type="testCodeFailure" message="thrown from sync fail todo">
|
||||
[Error [ERR_TEST_FAILURE]: thrown from sync fail todo] {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: Error: thrown from sync fail todo
|
||||
*
|
||||
@ -18,8 +19,7 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
at async Test.processPendingSubtests (node:internal/test_runner/test:374:7),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -27,6 +27,7 @@
|
||||
<skipped type="todo" message="this is a failing todo"/>
|
||||
<failure type="testCodeFailure" message="thrown from sync fail todo with message">
|
||||
[Error [ERR_TEST_FAILURE]: thrown from sync fail todo with message] {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: Error: thrown from sync fail todo with message
|
||||
*
|
||||
@ -35,8 +36,7 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
at async Test.processPendingSubtests (node:internal/test_runner/test:374:7),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -51,6 +51,7 @@
|
||||
<testcase name="sync throw fail" time="*" classname="test" failure="thrown from sync throw fail">
|
||||
<failure type="testCodeFailure" message="thrown from sync throw fail">
|
||||
[Error [ERR_TEST_FAILURE]: thrown from sync throw fail] {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: Error: thrown from sync throw fail
|
||||
*
|
||||
@ -59,8 +60,7 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
at async Test.processPendingSubtests (node:internal/test_runner/test:374:7),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -71,6 +71,7 @@
|
||||
<testcase name="async throw fail" time="*" classname="test" failure="thrown from async throw fail">
|
||||
<failure type="testCodeFailure" message="thrown from async throw fail">
|
||||
[Error [ERR_TEST_FAILURE]: thrown from async throw fail] {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: Error: thrown from async throw fail
|
||||
*
|
||||
@ -79,8 +80,7 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
at async Test.processPendingSubtests (node:internal/test_runner/test:374:7),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -88,6 +88,7 @@
|
||||
<skipped type="skipped" message="true"/>
|
||||
<failure type="testCodeFailure" message="thrown from async throw fail">
|
||||
[Error [ERR_TEST_FAILURE]: thrown from async throw fail] {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: Error: thrown from async throw fail
|
||||
*
|
||||
@ -96,8 +97,7 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
at async Test.processPendingSubtests (node:internal/test_runner/test:374:7),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -107,6 +107,7 @@
|
||||
|
||||
true !== false
|
||||
] {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
|
||||
|
||||
@ -124,8 +125,7 @@ true !== false
|
||||
actual: true,
|
||||
expected: false,
|
||||
operator: 'strictEqual'
|
||||
},
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
}
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -133,6 +133,7 @@ true !== false
|
||||
<testcase name="reject fail" time="*" classname="test" failure="rejected from reject fail">
|
||||
<failure type="testCodeFailure" message="rejected from reject fail">
|
||||
[Error [ERR_TEST_FAILURE]: rejected from reject fail] {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: Error: rejected from reject fail
|
||||
*
|
||||
@ -141,8 +142,7 @@ true !== false
|
||||
*
|
||||
*
|
||||
*
|
||||
at async Test.processPendingSubtests (node:internal/test_runner/test:374:7),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -156,6 +156,7 @@ true !== false
|
||||
<failure type="testCodeFailure" message="thrown from subtest sync throw fail">
|
||||
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: Error: thrown from subtest sync throw fail
|
||||
*
|
||||
@ -167,8 +168,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
|
||||
*
|
||||
*
|
||||
*
|
||||
at Test.postRun (node:internal/test_runner/test:715:19),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -176,7 +176,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
|
||||
</testsuite>
|
||||
<testcase name="sync throw non-error fail" time="*" classname="test" failure="Symbol(thrown symbol from sync throw non-error fail)">
|
||||
<failure type="testCodeFailure" message="Symbol(thrown symbol from sync throw non-error fail)">
|
||||
[Error [ERR_TEST_FAILURE]: Symbol(thrown symbol from sync throw non-error fail)] { failureType: 'testCodeFailure', cause: Symbol(thrown symbol from sync throw non-error fail), code: 'ERR_TEST_FAILURE' }
|
||||
[Error [ERR_TEST_FAILURE]: Symbol(thrown symbol from sync throw non-error fail)] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: Symbol(thrown symbol from sync throw non-error fail) }
|
||||
</failure>
|
||||
</testcase>
|
||||
<testsuite name="level 0a" time="*" disabled="0" errors="0" tests="4" failures="0" skipped="0" hostname="HOSTNAME">
|
||||
@ -188,7 +188,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
|
||||
<testsuite name="top level" time="*" disabled="0" errors="0" tests="2" failures="1" skipped="0" hostname="HOSTNAME">
|
||||
<testcase name="+long running" time="*" classname="test" failure="test did not finish before its parent and was cancelled">
|
||||
<failure type="cancelledByParent" message="test did not finish before its parent and was cancelled">
|
||||
[Error [ERR_TEST_FAILURE]: test did not finish before its parent and was cancelled] { failureType: 'cancelledByParent', cause: 'test did not finish before its parent and was cancelled', code: 'ERR_TEST_FAILURE' }
|
||||
[Error [ERR_TEST_FAILURE]: test did not finish before its parent and was cancelled] { code: 'ERR_TEST_FAILURE', failureType: 'cancelledByParent', cause: 'test did not finish before its parent and was cancelled' }
|
||||
</failure>
|
||||
</testcase>
|
||||
<testsuite name="+short running" time="*" disabled="0" errors="0" tests="1" failures="0" skipped="0" hostname="HOSTNAME">
|
||||
@ -205,6 +205,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
|
||||
<testcase name="sync skip option is false fail" time="*" classname="test" failure="this should be executed">
|
||||
<failure type="testCodeFailure" message="this should be executed">
|
||||
[Error [ERR_TEST_FAILURE]: this should be executed] {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: Error: this should be executed
|
||||
*
|
||||
@ -213,8 +214,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
|
||||
*
|
||||
*
|
||||
*
|
||||
at async Test.processPendingSubtests (node:internal/test_runner/test:374:7),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -236,11 +236,11 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
|
||||
<testcase name="callback fail" time="*" classname="test" failure="callback failure">
|
||||
<failure type="testCodeFailure" message="callback failure">
|
||||
[Error [ERR_TEST_FAILURE]: callback failure] {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: Error: callback failure
|
||||
*
|
||||
at process.processImmediate (node:internal/timers:478:21),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -249,12 +249,13 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
|
||||
<testcase name="callback t is this in test" time="*" classname="test"/>
|
||||
<testcase name="callback also returns a Promise" time="*" classname="test" failure="passed a callback but also returned a Promise">
|
||||
<failure type="callbackAndPromisePresent" message="passed a callback but also returned a Promise">
|
||||
[Error [ERR_TEST_FAILURE]: passed a callback but also returned a Promise] { failureType: 'callbackAndPromisePresent', cause: 'passed a callback but also returned a Promise', code: 'ERR_TEST_FAILURE' }
|
||||
[Error [ERR_TEST_FAILURE]: passed a callback but also returned a Promise] { code: 'ERR_TEST_FAILURE', failureType: 'callbackAndPromisePresent', cause: 'passed a callback but also returned a Promise' }
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase name="callback throw" time="*" classname="test" failure="thrown from callback throw">
|
||||
<failure type="testCodeFailure" message="thrown from callback throw">
|
||||
[Error [ERR_TEST_FAILURE]: thrown from callback throw] {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: Error: thrown from callback throw
|
||||
*
|
||||
@ -263,8 +264,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
|
||||
*
|
||||
*
|
||||
*
|
||||
at async Test.processPendingSubtests (node:internal/test_runner/test:374:7),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -273,9 +273,9 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
|
||||
Error [ERR_TEST_FAILURE]: callback invoked multiple times
|
||||
*
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'multipleCallbackInvocations',
|
||||
cause: 'callback invoked multiple times',
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
cause: 'callback invoked multiple times'
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -284,14 +284,14 @@ Error [ERR_TEST_FAILURE]: callback invoked multiple times
|
||||
<failure type="uncaughtException" message="callback invoked multiple times">
|
||||
Error [ERR_TEST_FAILURE]: callback invoked multiple times
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'uncaughtException',
|
||||
cause: Error [ERR_TEST_FAILURE]: callback invoked multiple times
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'multipleCallbackInvocations',
|
||||
cause: 'callback invoked multiple times',
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
},
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
cause: 'callback invoked multiple times'
|
||||
}
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -299,11 +299,11 @@ Error [ERR_TEST_FAILURE]: callback invoked multiple times
|
||||
<failure type="uncaughtException" message="thrown from callback async throw">
|
||||
Error [ERR_TEST_FAILURE]: thrown from callback async throw
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'uncaughtException',
|
||||
cause: Error: thrown from callback async throw
|
||||
*
|
||||
at process.processImmediate (node:internal/timers:478:21),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -319,7 +319,7 @@ Error [ERR_TEST_FAILURE]: thrown from callback async throw
|
||||
<!-- 'only' and 'runOnly' require the --test-only command-line option. -->
|
||||
<testcase name="custom inspect symbol fail" time="*" classname="test" failure="customized">
|
||||
<failure type="testCodeFailure" message="customized">
|
||||
[Error [ERR_TEST_FAILURE]: customized] { failureType: 'testCodeFailure', cause: customized, code: 'ERR_TEST_FAILURE' }
|
||||
[Error [ERR_TEST_FAILURE]: customized] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: customized }
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase name="custom inspect symbol that throws fail" time="*" classname="test" failure="{ foo: 1, [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]]}">
|
||||
@ -328,9 +328,9 @@ Error [ERR_TEST_FAILURE]: thrown from callback async throw
|
||||
foo: 1,
|
||||
[Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]]
|
||||
}] {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: { foo: 1, [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]] },
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
cause: { foo: 1, [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]] }
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -339,6 +339,7 @@ Error [ERR_TEST_FAILURE]: thrown from callback async throw
|
||||
<failure type="testCodeFailure" message="thrown from subtest sync throw fails at first">
|
||||
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: Error: thrown from subtest sync throw fails at first
|
||||
*
|
||||
@ -350,8 +351,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first
|
||||
*
|
||||
*
|
||||
*
|
||||
at Test.postRun (node:internal/test_runner/test:715:19),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -359,6 +359,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first
|
||||
<failure type="testCodeFailure" message="thrown from subtest sync throw fails at second">
|
||||
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: Error: thrown from subtest sync throw fails at second
|
||||
*
|
||||
@ -370,20 +371,19 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second
|
||||
*
|
||||
*
|
||||
*
|
||||
at async Test.run (node:internal/test_runner/test:632:9),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
</testsuite>
|
||||
<testcase name="timed out async test" time="*" classname="test" failure="test timed out after 5ms">
|
||||
<failure type="testTimeoutFailure" message="test timed out after 5ms">
|
||||
[Error [ERR_TEST_FAILURE]: test timed out after 5ms] { failureType: 'testTimeoutFailure', cause: 'test timed out after 5ms', code: 'ERR_TEST_FAILURE' }
|
||||
[Error [ERR_TEST_FAILURE]: test timed out after 5ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 5ms' }
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase name="timed out callback test" time="*" classname="test" failure="test timed out after 5ms">
|
||||
<failure type="testTimeoutFailure" message="test timed out after 5ms">
|
||||
[Error [ERR_TEST_FAILURE]: test timed out after 5ms] { failureType: 'testTimeoutFailure', cause: 'test timed out after 5ms', code: 'ERR_TEST_FAILURE' }
|
||||
[Error [ERR_TEST_FAILURE]: test timed out after 5ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 5ms' }
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase name="large timeout async test is ok" time="*" classname="test"/>
|
||||
@ -391,19 +391,19 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second
|
||||
<testcase name="successful thenable" time="*" classname="test"/>
|
||||
<testcase name="rejected thenable" time="*" classname="test" failure="custom error">
|
||||
<failure type="testCodeFailure" message="custom error">
|
||||
[Error [ERR_TEST_FAILURE]: custom error] { failureType: 'testCodeFailure', cause: 'custom error', code: 'ERR_TEST_FAILURE' }
|
||||
[Error [ERR_TEST_FAILURE]: custom error] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: 'custom error' }
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase name="unfinished test with uncaughtException" time="*" classname="test" failure="foo">
|
||||
<failure type="uncaughtException" message="foo">
|
||||
Error [ERR_TEST_FAILURE]: foo
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'uncaughtException',
|
||||
cause: Error: foo
|
||||
*
|
||||
*
|
||||
at process.processTimers (node:internal/timers:514:7),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -411,12 +411,12 @@ Error [ERR_TEST_FAILURE]: foo
|
||||
<failure type="unhandledRejection" message="bar">
|
||||
Error [ERR_TEST_FAILURE]: bar
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'unhandledRejection',
|
||||
cause: Error: bar
|
||||
*
|
||||
*
|
||||
at process.processTimers (node:internal/timers:514:7),
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
*
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -435,6 +435,7 @@ should loosely deep-equal
|
||||
bar: 2,
|
||||
c: [Circular *1]
|
||||
}] {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'testCodeFailure',
|
||||
cause: AssertionError [ERR_ASSERTION]: Expected values to be loosely deep-equal:
|
||||
|
||||
@ -455,8 +456,7 @@ should loosely deep-equal
|
||||
actual: [Object],
|
||||
expected: [Object],
|
||||
operator: 'deepEqual'
|
||||
},
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
}
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
@ -464,9 +464,9 @@ should loosely deep-equal
|
||||
<failure type="parentAlreadyFinished" message="test could not be started because its parent finished">
|
||||
Error [ERR_TEST_FAILURE]: test could not be started because its parent finished
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'parentAlreadyFinished',
|
||||
cause: 'test could not be started because its parent finished',
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
cause: 'test could not be started because its parent finished'
|
||||
}
|
||||
</failure>
|
||||
</testcase>
|
||||
|
@ -178,9 +178,9 @@
|
||||
callback called twice in future tick (*ms)
|
||||
Error [ERR_TEST_FAILURE]: callback invoked multiple times
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'multipleCallbackInvocations',
|
||||
cause: 'callback invoked multiple times',
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
cause: 'callback invoked multiple times'
|
||||
}
|
||||
|
||||
callback async throw (*ms)
|
||||
@ -449,9 +449,9 @@
|
||||
callback called twice in future tick (*ms)
|
||||
Error [ERR_TEST_FAILURE]: callback invoked multiple times
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'multipleCallbackInvocations',
|
||||
cause: 'callback invoked multiple times',
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
cause: 'callback invoked multiple times'
|
||||
}
|
||||
|
||||
*
|
||||
|
@ -178,9 +178,9 @@
|
||||
callback called twice in future tick (*ms)
|
||||
Error [ERR_TEST_FAILURE]: callback invoked multiple times
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'multipleCallbackInvocations',
|
||||
cause: 'callback invoked multiple times',
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
cause: 'callback invoked multiple times'
|
||||
}
|
||||
|
||||
callback async throw (*ms)
|
||||
@ -449,9 +449,9 @@
|
||||
callback called twice in future tick (*ms)
|
||||
Error [ERR_TEST_FAILURE]: callback invoked multiple times
|
||||
* {
|
||||
code: 'ERR_TEST_FAILURE',
|
||||
failureType: 'multipleCallbackInvocations',
|
||||
cause: 'callback invoked multiple times',
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
cause: 'callback invoked multiple times'
|
||||
}
|
||||
|
||||
*
|
||||
|
@ -5,7 +5,6 @@ node:internal/assert:*
|
||||
Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
|
||||
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
|
||||
|
||||
at new NodeError (node:internal/errors:*:*)
|
||||
at assert (node:internal/assert:*:*)
|
||||
at * (*test*message*internal_assert.js:7:1)
|
||||
at *
|
||||
|
@ -6,7 +6,6 @@ Error [ERR_INTERNAL_ASSERTION]: Unreachable!
|
||||
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
|
||||
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
|
||||
|
||||
at new NodeError (node:internal/errors:*:*)
|
||||
at Function.fail (node:internal/assert:*:*)
|
||||
at * (*test*message*internal_assert_fail.js:7:8)
|
||||
at *
|
||||
|
@ -207,8 +207,8 @@ async function ctrlCTest() {
|
||||
assert.deepStrictEqual(output.slice(0, 3), [
|
||||
'await new Promise(() => {})\r',
|
||||
'Uncaught:',
|
||||
'Error [ERR_SCRIPT_EXECUTION_INTERRUPTED]: ' +
|
||||
'Script execution was interrupted by `SIGINT`',
|
||||
'[Error [ERR_SCRIPT_EXECUTION_INTERRUPTED]: ' +
|
||||
'Script execution was interrupted by `SIGINT`] {',
|
||||
]);
|
||||
assert.deepStrictEqual(output.slice(-2), [
|
||||
'}',
|
||||
|
Loading…
Reference in New Issue
Block a user