Skip to content
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

svelte-kit dev crashes on page load if there is a syntax error in a layout component #843

Closed
Conduitry opened this issue Apr 3, 2021 · 2 comments
Labels
bug Something isn't working error handling

Comments

@Conduitry
Copy link
Member

Describe the bug
npm run dev/svelte-kit dev crashes on page load if there was a syntax error in the layout component when you started it.

Logs

/.../foo/node_modules/.pnpm/svelte@3.37.0/node_modules/svelte/compiler.js:16752
            const error = new CompileError(message);
                          ^

CompileError [ParseError]: Unexpected token
    at error (/.../foo/node_modules/.pnpm/svelte@3.37.0/node_modules/svelte/compiler.js:16752:20)
    at Parser$1.error (/.../foo/node_modules/.pnpm/svelte@3.37.0/node_modules/svelte/compiler.js:16828:10)
    at Parser$1.acorn_error (/.../foo/node_modules/.pnpm/svelte@3.37.0/node_modules/svelte/compiler.js:16822:15)
    at Object.read_script [as read] (/.../foo/node_modules/.pnpm/svelte@3.37.0/node_modules/svelte/compiler.js:7501:17)
    at tag (/.../foo/node_modules/.pnpm/svelte@3.37.0/node_modules/svelte/compiler.js:15887:34)
    at new Parser$1 (/.../foo/node_modules/.pnpm/svelte@3.37.0/node_modules/svelte/compiler.js:16787:22)
    at parse$3 (/.../foo/node_modules/.pnpm/svelte@3.37.0/node_modules/svelte/compiler.js:16919:21)
    at compile (/.../foo/node_modules/.pnpm/svelte@3.37.0/node_modules/svelte/compiler.js:29949:18)
    at compileSvelte (/.../foo/node_modules/.pnpm/@sveltejs/vite-plugin-svelte@1.0.0-next.5_svelte@3.37.0+vite@2.1.5/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:291:48)
    at TransformContext.transform (/.../foo/node_modules/.pnpm/@sveltejs/vite-plugin-svelte@1.0.0-next.5_svelte@3.37.0+vite@2.1.5/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:679:33) {
  code: 'parse-error',
  start: { line: 5, column: 0, character: 34 },
  end: { line: 5, column: 0, character: 34 },
  pos: 34,
  filename: '/.../foo/src/routes/$layout.svelte',
  frame: '3: \n4: +\n5: </script>\n   ^\n6: \n7: <slot />',
  plugin: 'vite-plugin-svelte',
  id: '/.../foo/src/routes/$layout.svelte',
  pluginCode: "<script>\n\timport '../app.css';\n\n+\n</script>\n\n<slot />\n",
  loc: {
    file: '/.../foo/src/routes/$layout.svelte',
    line: 4,
    column: 3
  }
}

To Reproduce
Edit src/routes/$layout.svelte to contain a syntax error that will cause an exception in the Svelte compiler. Start Kit in dev mode, and load the page in the browser.

Expected behavior
This should display some sort of 500 response in the browser.

Severity
Low-ish, but annoying.

Additional context
Syntax errors introduced after starting npm run dev in src/routes/$layout.svelte don't seem to be a problem, nor do syntax errors in other routes, even if they were present when starting the dev server.

@Conduitry Conduitry added bug Something isn't working error handling labels Apr 3, 2021
@Rich-Harris
Copy link
Member

I suspect this will be fixed as a side-effect of #626

@Conduitry
Copy link
Member Author

I think I recall trying this again after #626 and seeing that it was now fixed, but never closed this issue apparently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working error handling
Projects
None yet
Development

No branches or pull requests

2 participants