lib: fix ERR_INVALID_ARG_TYPE with --enable-source-maps · nodejs/node@3619dc0 · GitHub
Skip to content

Commit 3619dc0

Browse files
kimjune01aduh95
authored andcommitted
lib: fix ERR_INVALID_ARG_TYPE with --enable-source-maps
Signed-off-by: June Kim <kimjune01@gmail.com> PR-URL: #63215 Fixes: #63169 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 400d598 commit 3619dc0

6 files changed

Lines changed: 70 additions & 2 deletions

File tree

lib/internal/errors/error_source.js

Lines changed: 9 additions & 2 deletions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Flags: --enable-source-maps
2+
3+
import '../../../common/index.mjs';
4+
import { strict as assert } from 'node:assert';
5+
6+
// Regression test for https://github.com/nodejs/node/issues/63169
7+
// Under --enable-source-maps with no source map for this file, a failing
8+
// assert(value) must throw AssertionError, not TypeError ERR_INVALID_ARG_TYPE.
9+
assert(false); // eslint-disable-line no-restricted-syntax
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
node:internal/modules/run_main:<line>
2+
triggerUncaughtException(
3+
^
4+
5+
AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
6+
7+
assert(false)
8+
9+
at file://<project-root>/test/fixtures/source-map/output/source_map_assert_no_source_map.mjs:9:1
10+
at <node-internal-frames>
11+
at <node-internal-frames> {
12+
generatedMessage: true,
13+
code: 'ERR_ASSERTION',
14+
actual: false,
15+
expected: true,
16+
operator: '==',
17+
diff: 'simple'
18+
}
19+
20+
Node.js <node-version>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Flags: --enable-source-maps
2+
3+
'use strict';
4+
require('../../../common');
5+
const assert = require('node:assert');
6+
7+
// Regression test for https://github.com/nodejs/node/issues/63169
8+
// Under --enable-source-maps with no source map for this file, a failing
9+
// assert.ok(value) must throw AssertionError, not TypeError ERR_INVALID_ARG_TYPE.
10+
assert.ok(false); // eslint-disable-line no-restricted-syntax
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
node:internal/assert/utils:<line>
2+
throw error;
3+
^
4+
5+
AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
6+
7+
assert.ok(false)
8+
9+
at Object.<anonymous> (<project-root>/test/fixtures/source-map/output/source_map_assert_ok_no_source_map.cjs:10:8)
10+
at <node-internal-frames>
11+
at <node-internal-frames> {
12+
generatedMessage: true,
13+
code: 'ERR_ASSERTION',
14+
actual: false,
15+
expected: true,
16+
operator: '==',
17+
diff: 'simple'
18+
}
19+
20+
Node.js <node-version>

test/parallel/test-node-output-sourcemaps.mjs

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)