lib: fix ERR_INVALID_ARG_TYPE with --enable-source-maps#63215
Conversation
|
@kimjune01 I think the commit's module should be |
|
Good point — the root cause is in the source map resolution path, not assert itself. I'll update the title. |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
@kimjune01 please reword the commit as well 🙏🏽 |
629761d to
bef74dd
Compare
|
Done — reworded commit to |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #63215 +/- ##
=======================================
Coverage 90.03% 90.04%
=======================================
Files 713 713
Lines 224950 224957 +7
Branches 42532 42535 +3
=======================================
+ Hits 202542 202553 +11
- Misses 14175 14199 +24
+ Partials 8233 8205 -28
🚀 New features to boost your workflow:
|
|
@kimjune01 the CI failures all seem related to the changes |
| tmpdir.refresh(); | ||
|
|
||
| function runWithSourceMaps(filename, code) { | ||
| const filePath = path.join(tmpdir.path, filename); |
There was a problem hiding this comment.
Can this test use a fixture like test/parallel/test-node-output-sourcemaps.mjs rather than generating source codes dynamically?
6eddc82 to
4b39cd1
Compare
|
Rebased onto current main and fixed the two lint failures:
The earlier build failures looked unrelated to this lib/ change; should be clean on the fresh run. |
Signed-off-by: June Kim <kimjune01@gmail.com>
4b39cd1 to
6a0b05f
Compare
| } | ||
|
|
||
| test('assert(false) in .mjs with --enable-source-maps throws AssertionError', () => { | ||
| const result = runWithSourceMaps('assert-no-source-map.mjs'); |
There was a problem hiding this comment.
Would you mind follow the setups in test/parallel/test-node-output-sourcemaps.mjs? These two test cases can be added to the existing output test.
When
--enable-source-mapsis enabled but no source map exists for the script (e.g. a plain.mjsfile),getErrorSourceLocation()returnedundefined. This causedgetErrMessage()to returnundefined, which madeinnerOk()pass[undefined]as the message tuple toinnerFail(), hitting theERR_INVALID_ARG_TYPEguard instead of throwingAssertionError.Fix all code paths in
getErrorSourceLocation()that returned bareundefinedto 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
.mjsand.cjsfiles under--enable-source-maps.Fixes: #63169