Repository navigation
TS transforms not working when source file path contains some chars #56296
Copy link
Copy link
Closed
Labels
source mapsIssues and PRs related to source map support.Issues and PRs related to source map support.test_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.
Description
Version
main
Platform
N/A
Subsystem
No response
What steps will reproduce the bug?
$ cat test/fixtures/test-runner/matching-patterns/typescript-test.cts
const test = require('node:test');
// 'as string' ensures that type stripping actually occurs
test('this should pass' as string);
$ cp test/fixtures/test-runner/matching-patterns/typescript-test.cts dir%20with\ \$unusual\"chars\?\'åß∂ƒ©∆¬…\`.cts
$ ./node --experimental-transform-types dir%20with\ \$unusual\"chars\?\'åß∂ƒ©∆¬…\`.cts
node:internal/errors:540
throw error;
^
TypeError [ERR_INVALID_ARG_TYPE]: The "payload" argument must be of type object. Received null
at cloneSourceMapV3 (node:internal/source_map/source_map:365:3)
at new SourceMap (node:internal/source_map/source_map:145:21)
at findSourceMap (node:internal/source_map/source_map_cache:348:17)
at lazyFindSourceMap (node:internal/test_runner/test:98:10)
at new Test (node:internal/test_runner/test:556:21)
at createTestTree (node:internal/test_runner/harness:82:16)
at lazyBootstrapRoot (node:internal/test_runner/harness:264:5)
at run (node:internal/test_runner/harness:302:61)
at test (node:internal/test_runner/harness:317:12)
at Object.<anonymous> (…/dir%20with $unusual"chars?'åß∂ƒ©∆¬…`.cts:3:1) {
code: 'ERR_INVALID_ARG_TYPE'
}
Node.js v24.0.0-preHow often does it reproduce? Is there a required condition?
Required condition: source file path contains some special chars (not sure which)
What is the expected behavior? Why is that the expected behavior?
It should not throw
What do you see instead?
TypeError [ERR_INVALID_ARG_TYPE]: The "payload" argument must be of type object. Received null
at cloneSourceMapV3 (node:internal/source_map/source_map:365:3)
at new SourceMap (node:internal/source_map/source_map:145:21)
at findSourceMap (node:internal/source_map/source_map_cache:348:17)
at lazyFindSourceMap (node:internal/test_runner/test:98:10)
at new Test (node:internal/test_runner/test:556:21)
at createTestTree (node:internal/test_runner/harness:82:16)
at lazyBootstrapRoot (node:internal/test_runner/harness:264:5)
at run (node:internal/test_runner/harness:302:61)
at test (node:internal/test_runner/harness:317:12)
at Object.<anonymous> (…/dir%20with $unusual"chars?'åß∂ƒ©∆¬…`.cts:3:1) {
code: 'ERR_INVALID_ARG_TYPE'
}
Additional information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
source mapsIssues and PRs related to source map support.Issues and PRs related to source map support.test_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.
Activity
marco-ippolito commentedon Dec 17, 2024
Cc @legendecas
legendecas commentedon Dec 18, 2024
FWIW, this is not related to this forged path. This is due to the source map generated with
--experimental-tranform-typesis invalid, like//# sourceMappingURL=data:application/json;base64,-1. Anyway, this should not crash the test runner.#56299 should fix this.
aduh95 commentedon Dec 18, 2024
I've tried pulling #56299 into #48409, there's still an issue with e.g.
test/fixtures/typescript/ts/test-get-callsite.ts, where the ability to generate a correct source map is dependent on the presence of some chars in the path.Notice the reported
lineNumberis not the same, indicating I think the source map is not being generated correctly.legendecas commentedon Dec 19, 2024
This sounds like a separate issue from the original crash issue. Submitted #56315 to fix the generation of the invalid source map url.
module: use buffer.toString base64
lib: suppress source map lookup exceptions
lib: optimize `prepareStackTrace` on builtin frames
module: use buffer.toString base64
lib: suppress source map lookup exceptions
lib: optimize `prepareStackTrace` on builtin frames
module: use buffer.toString base64
lib: suppress source map lookup exceptions
lib: optimize `prepareStackTrace` on builtin frames
lib: suppress source map lookup exceptions
lib: optimize `prepareStackTrace` on builtin frames