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

Errors in the first two lines of server-side endpoints are not reported #3243

Closed
lovasoa opened this issue Jan 8, 2022 · 5 comments · Fixed by #4468
Closed

Errors in the first two lines of server-side endpoints are not reported #3243

lovasoa opened this issue Jan 8, 2022 · 5 comments · Fixed by #4468
Labels
bug Something isn't working vite
Milestone

Comments

@lovasoa
Copy link
Contributor

lovasoa commented Jan 8, 2022

Describe the bug

When the first line of a server-side endpoint contains an error, the dev server displays TypeError: Line must be greater than or equal to 1, got -1 instead of showing the actual error.

Reproduction

Create a svelte-kit project and paste this in src/routes/server-side.js

/** @type {import('@sveltejs/kit').RequestHandler} */
export async function get({ params }) {
		return {
			body: "Hello world"
		};
}

then start the dev server, load http://localhost:3000/server-route in your browser

Then add a line at the top of the file, containing thisvariableisnotdefined, so as to get

thisvariableisnotdefined

/** @type {import('@sveltejs/kit').RequestHandler} */
export async function get({ params }) {
		return {
			body: "Hello world"
		};
}

Logs

TypeError: Line must be greater than or equal to 1, got -1
    at BasicSourceMapConsumer.SourceMapConsumer_findMapping [as _findMapping] (/tmp/bug3118/node_modules/vite/dist/node/chunks/dep-76613303.js:58876:13)
    at BasicSourceMapConsumer.SourceMapConsumer_originalPositionFor [as originalPositionFor] (/tmp/bug3118/node_modules/vite/dist/node/chunks/dep-76613303.js:58945:22)
    at /tmp/bug3118/node_modules/vite/dist/node/chunks/dep-76613303.js:59886:34
    at String.replace (<anonymous>)
    at /tmp/bug3118/node_modules/vite/dist/node/chunks/dep-76613303.js:59874:21
    at Array.map (<anonymous>)
    at ssrRewriteStacktrace (/tmp/bug3118/node_modules/vite/dist/node/chunks/dep-76613303.js:59873:10)
    at Object.ssrFixStacktrace (/tmp/bug3118/node_modules/vite/dist/node/chunks/dep-76613303.js:60365:36)
    at Object.handle_error (file:///tmp/bug3118/node_modules/@sveltejs/kit/dist/chunks/index.js:4392:15)
    at respond (file:///tmp/bug3118/node_modules/@sveltejs/kit/dist/ssr.js:1841:11)

System Info

System:
    OS: Linux 5.15 Fedora Linux 35 (Workstation Edition)
    CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
    Memory: 1.75 GB / 15.28 GB
    Container: Yes
    Shell: 5.1.8 - /bin/bash
  Binaries:
    Node: 16.13.0 - /usr/bin/node
    Yarn: 1.22.10 - /usr/bin/yarn
    npm: 8.1.0 - /usr/bin/npm
  Browsers:
    Firefox: 95.0
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.10 
    @sveltejs/kit: next => 1.0.0-next.218 
    svelte: ^3.44.0 => 3.45.0

Severity

annoyance

Additional Information

No response

lovasoa added a commit to lovasoa/sveltekit-bug-3118 that referenced this issue Jan 8, 2022
@benmccann
Copy link
Member

Reproduction here: https://github.com/lovasoa/sveltekit-bug-3118

@benmccann
Copy link
Member

@lovasoa can you check if this is reproducible with Vite without SvelteKit? I imagine that it would be and should be filed there. See https://github.com/sveltejs/kit#bug-reporting for more details

@Rich-Harris
Copy link
Member

This is difficult (not impossible, but difficult) to fix because it's hard to know if a stack trace has already been fixed by Vite. I've opened vitejs/vite#7046

@Rich-Harris
Copy link
Member

Should be an easy fix when we next update Vite: vitejs/vite#7048

@benmccann benmccann added this to the 1.0 milestone Mar 30, 2022
@benmccann benmccann added the bug Something isn't working label Mar 30, 2022
@lovasoa
Copy link
Contributor Author

lovasoa commented Mar 31, 2022

🎉

Thanks @Rich-Harris !

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

Successfully merging a pull request may close this issue.

3 participants