fix(utils): don't crash on a malformed inline source map (fix #10892) - #10893
Conversation
|
Both failing jobs look unrelated to this change. The Windows unit job fails the same way on main, in the typechecker OOM test. The macOS e2e job failed on a watch fixture that disappeared mid-run. |
hi-ogawa
left a comment
There was a problem hiding this comment.
Should also try integration repro in vite and fix there too
vitest/packages/utils/src/source-map/node.ts
Lines 9 to 11 in 9ac9d43
|
I checked vite's own extractSourcemapFromFile (packages/vite/src/node/server/sourcemap.ts). Both call sites already wrap it in try/catch, and the module runner has a separate fix (#20554) for the same sourceMappingURL-in-a-string-literal case, so this crash doesn't happen there and no follow-up is needed on that side. |
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
| // Split across a concat so this file's own transform doesn't treat it as | ||
| // its own (malformed) source map comment. | ||
| const malformedSourceMapComment = '//# source' + 'MappingURL=data:application/json;base64,bm90LWpzb24=' | ||
|
|
||
| const { stderr, exitCode, buildTree } = await runInlineTests({ | ||
| 'malformed-source-map.js': `${malformedSourceMapComment} |
There was a problem hiding this comment.
Can use real file fixture for better illustration.
There was a problem hiding this comment.
Switched to a real fixture file, thanks for the nudge.
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
Co-authored-by: OpenCode <noreply@opencode.ai>
| // TODO: this uses client module graph and thus miss detects | ||
| // inlined modules in ssr environment as if external. |
There was a problem hiding this comment.
Apparently test/e2e/fixtures/malformed-source-map/malformed-source-map.js case shouldn't have failed if we got this right. For now, just leaving inline TODO here and not creating its own issue since this misdetection doesn't have actually any consequence for mapping correctness (as we've covered extensively in other e2e).
Description
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.