Skip to content

lib: 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

lib: 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
@atlowChemi atlowChemi added the source maps Issues and PRs related to source map support. label May 10, 2026
@atlowChemi
Copy link
Copy Markdown
Member

@kimjune01 I think the commit's module should be lib, not assert, as I don't think this changes assert specifically, that is mostly the symptom, not the actual issue, no?

@kimjune01
Copy link
Copy Markdown
Author

Good point β€” the root cause is in the source map resolution path, not assert itself. I'll update the title.

@kimjune01 kimjune01 changed the title assert: fix ERR_INVALID_ARG_TYPE with --enable-source-maps lib: fix ERR_INVALID_ARG_TYPE with --enable-source-maps May 10, 2026
@idabeck-cpu

This comment was marked as spam.

@idabeck-cpu

This comment was marked as spam.

@idabeck-cpu

This comment was marked as spam.

@atlowChemi
Copy link
Copy Markdown
Member

Good point β€” the root cause is in the source map resolution path, not assert itself. I'll update the title.

@kimjune01 please reword the commit as well πŸ™πŸ½
Let me know if any help is needed

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. source maps Issues and PRs related to source map support.

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)

4 participants