-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
fix(module-runner): prevent crash when sourceMappingURL pattern appears in string literals #20554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
1cad4a7
5de6472
38afca3
545f586
e3a280c
c94ab91
2e3126c
9058401
76e0cff
67b5890
45ed63a
29177ba
7695ec6
22c56ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // This file contains sourceMappingURL pattern in string literals | ||
| // which should not crash the module runner | ||
|
|
||
| const text = '//# sourceMappingURL=data:application/json;base64,invalidbase64' | ||
|
|
||
| export function getMessage() { | ||
| return text | ||
| } | ||
|
|
||
| export function throwError() { | ||
| throw new Error('Test error for stacktrace') | ||
| } | ||
sapphi-red marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,8 +89,20 @@ | |
| }) | ||
| expect(serializeStackDeep(server, methodError).slice(0, 3)).toEqual([ | ||
| 'Error: crash', | ||
| ' at crash (<root>/fixtures/has-error-deep.ts:2:9)', | ||
|
Check failure on line 92 in packages/vite/src/node/ssr/runtime/__tests__/server-source-maps.spec.ts
|
||
| ' at Module.main (<root>/fixtures/has-error-deep.ts:6:3)', | ||
|
Check failure on line 93 in packages/vite/src/node/ssr/runtime/__tests__/server-source-maps.spec.ts
|
||
| ]) | ||
| }) | ||
|
|
||
| it('should not crash when sourceMappingURL pattern appears in string literals', async ({ | ||
| runner, | ||
| }) => { | ||
| const mod = await runner.import('/fixtures/string-literal-sourcemap.ts') | ||
| expect(mod.getMessage()).toBe( | ||
| '//# sourceMappingURL=data:application/json;base64,invalidbase64', | ||
| ) | ||
|
|
||
| const error = await getError(() => mod.throwError()) | ||
| expect(error.message).toBe('Test error for stacktrace') | ||
sapphi-red marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }) | ||
| }) | ||
Uh oh!
There was an error while loading. Please reload this page.