-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
fix: handle error in numberToPos and formatError #4782
Conversation
deprecated acorn-numeric-separator@0.3.6: acorn>=7.4 supports numeric separators
rollup hangs with typescript 4.4.2 rollup/plugins#983
deprecated acorn-numeric-separator@0.3.6: acorn>=7.4 supports numeric separators
rollup hangs with typescript 4.4.2 rollup/plugins#983
rollup hangs with typescript 4.4.2 rollup/plugins#983
let errLocation; | ||
try { | ||
errLocation = numberToPos(ctx._activeCode, pos); | ||
} | ||
catch (err2) { | ||
logger.error( | ||
chalk.red(`Error in error handler:\n${err2.stack || err2.message}`), | ||
{ error: err2 } | ||
) | ||
// TODO verify that err is visible | ||
throw err; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO verify that err is visible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how to add a unit test for this?
vite.createServer -> createPluginContainer -> formatError
broken code is passed to the plugin -> plugin throws error1
plugin returns a broken sourcemap -> numberToPos throws error2 "offset is longer than source length"
scripts/jestPerTestSetup.ts calls server = await (await createServer(options)).listen()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patak-js Do we even test logged errors?
I'm not sure if we need to test this 🤔
Converted to draft until |
done manually, this is non-trivial to test note: this is NOT visible in $ npm run dev > @ dev svelte/mdsvex/sveltekit-bugs > svelte-kit dev Pre-bundling dependencies: svelte/store svelte svelte/animate svelte/easing svelte/internal (...and 2 more) (this will be run only when your dependencies or config have changed) SvelteKit v1.0.0-next.159 local: http://localhost:3000 network: not exposed Use --host to expose server to other devices on this network Error in error handler: Error: offset is longer than source length! offset 126 > length 48 at numberToPos (vite/dist/node/chunks/dep-7017d082.js:4256:15) at formatError (vite/dist/node/chunks/dep-7017d082.js:50004:35) at TransformContext.error (vite/dist/node/chunks/dep-7017d082.js:49984:19) at Object.transform (vite/dist/node/chunks/dep-7017d082.js:50200:25) at async transformRequest (vite/dist/node/chunks/dep-7017d082.js:64964:29) at async instantiateModule (vite/dist/node/chunks/dep-7017d082.js:74748:10) Expected valid tag name 4: </script> 5: 6: <p>Lorem ipsum < dolor sit</p> ^ ParseError: Expected valid tag name at error (svelte/compiler.mjs:17697:19) at Parser$1.error (svelte/compiler.mjs:17773:9) at read_tag_name (svelte/compiler.mjs:16918:16) at tag (svelte/compiler.mjs:16768:18) at new Parser$1 (svelte/compiler.mjs:17732:21) at parse$3 (svelte/compiler.mjs:17864:20) at compile (svelte/compiler.mjs:31303:17) at compileSvelte (vite-plugin-svelte/dist/index.js:301:20) at async TransformContext.transform (vite-plugin-svelte/dist/index.js:1325:27) at async Object.transform (vite/dist/node/chunks/dep-7017d082.js:50197:30) |
deprecated acorn-numeric-separator@0.3.6: acorn>=7.4 supports numeric separators
note: currently, the browser runtime shows only the second error
|
old behavior
for example
new behavior
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).