Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
a636338
src: allow creating NodeMainInstance that does not own the isolate
joyeecheung Apr 19, 2019
631bea8
src: implement IsolateData serialization and deserialization
joyeecheung Apr 18, 2019
b44323f
tools: implement node_mksnapshot
joyeecheung Apr 18, 2019
45d6106
src: enable snapshot with per-isolate data
joyeecheung Apr 18, 2019
228127f
src: enable context snapshot after running per-context scripts
joyeecheung Apr 20, 2019
ad42cd6
src: use std::vector<size_t> instead of IndexArray
joyeecheung Apr 21, 2019
a6d1fa5
doc: simplify Collaborator pre-nomination text
Trott Apr 22, 2019
d62a324
tools: update tools/license-builder.sh
ryzokuken Apr 23, 2019
5023446
build: disable custom v8 snapshot by default
joyeecheung Apr 23, 2019
f70588f
doc: fix v12.0.0 changelog id
BethGriggs Apr 23, 2019
8ca110c
benchmark: fix http bench-parser.js
Trott Apr 23, 2019
8486917
test: increase coverage in lib/internal/dns/promises.js
Trott Apr 21, 2019
ee80a21
dgram: change 'this' to 'self' for 'isConnected'
Apr 22, 2019
d84a6d0
test: make test-worker-esm-missing-main more robust
Trott Apr 22, 2019
f0b2992
test: fix ineffective error tests
Apr 21, 2019
481789c
tools: fix use-after-free mkcodecache warning
bnoordhuis Apr 21, 2019
3676288
doc: clarify behaviour of writeFile(fd)
sam-github Apr 17, 2019
7bc47cb
src: apply clang-tidy rule modernize-use-equals-default
gengjiawen Apr 16, 2019
809cf59
src: add `Environment` overload of `EmitAsyncDestroy`
addaleax Apr 16, 2019
8b5d738
n-api: do not require JS Context for `napi_async_destroy()`
addaleax Apr 16, 2019
619c5b6
src: do not require JS Context for `~AsyncResoure()`
addaleax Apr 16, 2019
453510c
doc: fix pull request number
BridgeAR Apr 21, 2019
dd709fc
lib: throw a special error in internal/assert
joyeecheung Mar 13, 2019
4dfe54a
module: initialize module_wrap.callbackMap during pre-execution
joyeecheung Apr 20, 2019
973d705
util: improve `Symbol.toStringTag` handling
BridgeAR Apr 22, 2019
8f34428
util: rename setIteratorBraces to getIteratorBraces
BridgeAR Apr 22, 2019
ebbed60
test: rework to remove flakiness, and be parallel
sam-github Apr 22, 2019
d852d9e
deps: update ICU to 64.2
ryzokuken Apr 23, 2019
53f0ef3
tools: update LICENSE and tools/icu/current_ver.dep
ryzokuken Apr 23, 2019
dcbe5b9
tools: update certdata.txt
sam-github Apr 23, 2019
b21b28f
crypto: update root certificates
sam-github Apr 23, 2019
2f9bafb
bootstrap: delay the instantiation of maps in per-context scripts
joyeecheung Apr 23, 2019
8089d29
src: apply clang-tidy modernize-deprecated-headers found by Jenkins CI
gengjiawen Apr 17, 2019
81e7b49
src: use predefined AliasedBuffer types in the code base
joyeecheung Apr 21, 2019
9c30806
doc: simplify GOVERNANCE.md text
Trott Apr 23, 2019
8302148
Add Node 12 to the first list of versions
rivajunior Apr 25, 2019
071300b
src: move OnMessage to node_errors.cc
joyeecheung Apr 19, 2019
e7026f1
build: allow icu download to use other hashes besides md5
srl295 Apr 23, 2019
ae2333d
util: add prototype support for boxed primitives
BridgeAR Apr 22, 2019
6ca0270
tls: include invalid method name in thrown error
sam-github Apr 24, 2019
f6ceefa
doc: update comment in bootstrap for primordials
MylesBorins Apr 24, 2019
e9021cc
test: move test-net-connect-handle-econnrefused
lpinca Mar 30, 2019
50732c1
test: refactor net-connect-handle-econnrefused
lpinca Mar 30, 2019
3614a00
src: refactor deprecated UVException in node_file.cc
gengjiawen Apr 17, 2019
e922a22
deps: backport ICU-20558 to fix Intl crasher
srl295 Apr 25, 2019
3282ccb
deps: backport ICU-20575 to fix err/crasher
srl295 Apr 25, 2019
dc510fb
report: print common items first for readability
gengjiawen Apr 23, 2019
d00014e
process: reduce the number of internal frames in async stack trace
joyeecheung Apr 24, 2019
bf12414
2019-04-29, Version 12.1.0 (Current)
targos Apr 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lib: throw a special error in internal/assert
Instead of using the public AssertionError, use a simplified
error that describes potential causes of these assertions
and suggests the user to open an issue.

PR-URL: #26635
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
joyeecheung authored and targos committed Apr 27, 2019
commit dd709fc84a6c04408221d096ca8e738b8fe4e870
6 changes: 6 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,12 @@ is set for the `Http2Stream`.
`http2.connect()` was passed a URL that uses any protocol other than `http:` or
`https:`.

<a id="ERR_INTERNAL_ASSERTION"></a>
### ERR_INTERNAL_ASSERTION

There was a bug in Node.js or incorrect usage of Node.js internals.
To fix the error, open an issue at https://github.com/nodejs/node/issues.

<a id="ERR_INCOMPATIBLE_OPTION_PAIR"></a>
### ERR_INCOMPATIBLE_OPTION_PAIR

Expand Down
13 changes: 11 additions & 2 deletions lib/internal/assert.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
'use strict';

let error;
function lazyError() {
if (!error) {
error = require('internal/errors').codes.ERR_INTERNAL_ASSERTION;
}
return error;
}
function assert(value, message) {
if (!value) {
require('assert')(value, message);
const ERR_INTERNAL_ASSERTION = lazyError();
throw new ERR_INTERNAL_ASSERTION(message);
}
}

function fail(message) {
require('assert').fail(message);
const ERR_INTERNAL_ASSERTION = lazyError();
throw new ERR_INTERNAL_ASSERTION(message);
}

assert.fail = fail;
Expand Down
7 changes: 7 additions & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,13 @@ E('ERR_INSPECTOR_CLOSED', 'Session was closed', Error);
E('ERR_INSPECTOR_COMMAND', 'Inspector error %d: %s', Error);
E('ERR_INSPECTOR_NOT_AVAILABLE', 'Inspector is not available', Error);
E('ERR_INSPECTOR_NOT_CONNECTED', 'Session is not connected', Error);
E('ERR_INTERNAL_ASSERTION', (message) => {
const suffix = 'This is caused by either a bug in Node.js ' +
'or incorrect usage of Node.js internals.\n' +
'Please open an issue with this stack trace at ' +
'https://github.com/nodejs/node/issues\n';
return message === undefined ? suffix : `${message}\n${suffix}`;
}, Error);
E('ERR_INVALID_ADDRESS_FAMILY', function(addressType, host, port) {
this.host = host;
this.port = port;
Expand Down
14 changes: 14 additions & 0 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,19 @@ function expectsError(fn, settings, exact) {
return mustCall(innerFn, exact);
}

const suffix = 'This is caused by either a bug in Node.js ' +
'or incorrect usage of Node.js internals.\n' +
'Please open an issue with this stack trace at ' +
'https://github.com/nodejs/node/issues\n';

function expectsInternalAssertion(fn, message) {
assert.throws(fn, {
message: `${message}\n${suffix}`,
name: 'Error',
code: 'ERR_INTERNAL_ASSERTION'
});
}

function skipIfInspectorDisabled() {
if (!process.features.inspector) {
skip('V8 inspector is disabled');
Expand Down Expand Up @@ -729,6 +742,7 @@ module.exports = {
enoughTestCpu,
enoughTestMem,
expectsError,
expectsInternalAssertion,
expectWarning,
getArrayBufferViews,
getBufferSources,
Expand Down
7 changes: 7 additions & 0 deletions test/message/internal_assert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

// Flags: --expose-internals
require('../common');

const assert = require('internal/assert');
assert(false);
15 changes: 15 additions & 0 deletions test/message/internal_assert.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
internal/assert.js:*
throw new ERR_INTERNAL_ASSERTION(message);
^

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 assert (internal/assert.js:*:*)
at * (*test*message*internal_assert.js:7:1)
at *
at *
at *
at *
at *
at *
7 changes: 7 additions & 0 deletions test/message/internal_assert_fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

// Flags: --expose-internals
require('../common');

const assert = require('internal/assert');
assert.fail('Unreachable!');
16 changes: 16 additions & 0 deletions test/message/internal_assert_fail.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
internal/assert.js:*
throw new ERR_INTERNAL_ASSERTION(message);
^

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 Function.fail (internal/assert.js:*:*)
at * (*test*message*internal_assert_fail.js:7:8)
at *
at *
at *
at *
at *
at *
10 changes: 3 additions & 7 deletions test/parallel/test-internal-assert.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
// Flags: --expose-internals
'use strict';

// This tests that the internal assert module works as expected.
// The failures are tested in test/message.

require('../common');

const assert = require('assert');
const internalAssert = require('internal/assert');

// Should not throw.
internalAssert(true);
internalAssert(true, 'fhqwhgads');

assert.throws(() => { internalAssert(false); }, assert.AssertionError);
assert.throws(() => { internalAssert(false, 'fhqwhgads'); },
{ code: 'ERR_ASSERTION', message: 'fhqwhgads' });
assert.throws(() => { internalAssert.fail('fhqwhgads'); },
{ code: 'ERR_ASSERTION', message: 'fhqwhgads' });
8 changes: 3 additions & 5 deletions test/parallel/test-internal-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ errors.E('TEST_ERROR_2', (a, b) => `${a} ${b}`, Error);
}

{
assert.throws(
common.expectsInternalAssertion(
() => new errors.codes.TEST_ERROR_1(),
{
message: 'Code: TEST_ERROR_1; The provided arguments ' +
'length (0) does not match the required ones (1).'
}
'Code: TEST_ERROR_1; The provided arguments ' +
'length (0) does not match the required ones (1).'
);
}

Expand Down
7 changes: 2 additions & 5 deletions test/parallel/test-tls-basic-validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,9 @@ common.expectsError(
assert.throws(() => tls.createServer({ ticketKeys: Buffer.alloc(0) }),
/TypeError: Ticket keys length must be 48 bytes/);

common.expectsError(
common.expectsInternalAssertion(
() => tls.createSecurePair({}),
{
code: 'ERR_ASSERTION',
message: 'context.context must be a NativeSecureContext'
}
'context.context must be a NativeSecureContext'
);

{
Expand Down
18 changes: 9 additions & 9 deletions test/sequential/test-fs-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ tmpdir.refresh();
// https://github.com/joyent/node/issues/6690
{
let oldhandle;
assert.throws(() => {
const w = fs.watch(__filename, common.mustNotCall());
oldhandle = w._handle;
w._handle = { close: w._handle.close };
w.close();
}, {
message: 'handle must be a FSEvent',
code: 'ERR_ASSERTION'
});
common.expectsInternalAssertion(
() => {
const w = fs.watch(__filename, common.mustNotCall());
oldhandle = w._handle;
w._handle = { close: w._handle.close };
w.close();
},
'handle must be a FSEvent'
);
oldhandle.close(); // clean up
}