Skip to content

assert: fix ERR_INVALID_ARG_TYPE with --enable-source-maps#63215

Open
kimjune01 wants to merge 1 commit intonodejs:mainfrom
kimjune01:fix/assert-source-maps-regression
Open

assert: fix ERR_INVALID_ARG_TYPE with --enable-source-maps#63215
kimjune01 wants to merge 1 commit intonodejs:mainfrom
kimjune01:fix/assert-source-maps-regression

Conversation

@kimjune01
Copy link
Copy Markdown

When --enable-source-maps is enabled but no source map exists for the script (e.g. a plain .mjs file), getErrorSourceLocation() returned undefined. This caused getErrMessage() to return undefined, which made innerOk() pass [undefined] as the message tuple to innerFail(), hitting the ERR_INVALID_ARG_TYPE guard instead of throwing AssertionError.

Fix all code paths in getErrorSourceLocation() that returned bare undefined to fall back to the raw generated source line, matching the behavior when source maps are disabled entirely. Also add a guard for when V8 fails to provide a source line at all.

Includes tests for both .mjs and .cjs files under --enable-source-maps.

Fixes: #63169

When --enable-source-maps is enabled but no source map is registered for
a script (e.g. a plain .mjs file), getErrorSourceLocation() returned
undefined. This caused getErrMessage() to return undefined, which made
innerOk() pass [undefined] as the message tuple to innerFail(), hitting
the ERR_INVALID_ARG_TYPE guard instead of throwing an AssertionError.

Fix all code paths in getErrorSourceLocation() that returned bare
undefined to fall back to the raw generated source line, matching
the behavior when source maps are disabled entirely. Also add a
defensive guard for when V8 fails to provide a source line at all.

Fixes: nodejs#63169
@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originated in Node.js core. needs-ci PRs that need a full CI run. labels May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

errors Issues and PRs related to JavaScript errors originated in Node.js core. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

assert: ERR_INVALID_ARG_TYPE on failing assert(value) under --enable-source-maps (v26 regression)

2 participants