stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.89k stars 160 forks source link

Vite crashes when it shouldn't with "line must be greater than 0" #1240

Open Readf0x opened 1 year ago

Readf0x commented 1 year ago

Describe the bug

Very often when I'm using stackblitz, I'll make a change to my code that will create an error. Oh well, no biggie, vite will let me just undo the change and, wait what do you mean vite crashed? That's not supposed to happen. So I check the error log and I see:

Error: `line` must be greater than 0 (lines start at line 1)
    at originalPositionFor$1 (/home/Readf0x/site-rewrite/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:10179:19)
    at eval (/home/Readf0x/site-rewrite/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:55901:25)
    at eval (/home/Readf0x/site-rewrite/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:55892:21)
    at ssrRewriteStacktrace (/home/Readf0x/site-rewrite/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:55891:10)
    at ssrFixStacktrace (/home/Readf0x/site-rewrite/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:55944:24)
    at Object.ssrFixStacktrace (/home/Readf0x/site-rewrite/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:65132:13)
    at fix_stack_trace (/home/Readf0x/site-rewrite/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:273:8)
    at eval (/home/Readf0x/site-rewrite/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:547:13)

Right now, I'm encountering this error whenever I edit a specific css file. Since I'm currently working on the slowest laptop known to man, it can take upwards of 20s to restart the vite server, and css is something I have to edit quite frequently.

I really couldn't tell you why this happens, but it is a frequent occurrence. It also occurs when you go to a route that doesn't exist without a dynamic route error handler.

Link to the blitz that caused the error

https://stackblitz.com/github/Readf0x/site-rewrite/tree/d0bc67bf20e7ecafb65b320965cdf20bc36ebdf2?file=src%2Flib%2Fprism%2Fcatppuccin.css

Steps to reproduce

In the preview, navigate to the "/about" route (accessible navbar, hamburger menu if preview has small width, or direct url) Edit css file Upon attempt to reload page, vite will crash with Error: `line` must be greater than 0 (lines start at line 1)

Expected behavior

Vite should not crash in this instance, it should at worst return with a 500 internal server error.

Parity with Local

Screenshots

No response

Platform

Version = 1.80.0
Hash = 1237962aa439bdb72a334d69943149e74bd625c0
WebContainer = 5a198b5c

Browser name  = Chrome
Full version  = 119.0.0.0
Major version = 119
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0
performance.memory = {
  "totalJSHeapSize": 298828266,
  "usedJSHeapSize": 288913566,
  "jsHeapSizeLimit": 2172649472
}

Additional context

The exact line I'm editing is line 35. There is a 100% chance of this error occurring when changing the rule name from "overflow-x" to "overflow".

jrvidal commented 1 year ago

:wave: Thanks for the report, this looks like a bug on our side. I've now added it to our internal tracker.

Readf0x commented 1 year ago

:wave: Thanks for the report, this looks like a bug on our side. I've now added it to our internal tracker.

Sorry about the lack of professionalism, I was extremely annoyed at the time of posting :P

hybridherbst commented 8 months ago

The issue still happens. For me, it happens basically whenever I do anything with Sveltekit on StackBlitz at some point, and from then on it's impossible to get it to work again.

Reproduction page: https://stackblitz.com/edit/sveltejs-kit-template-default-36pavj?file=package.json

@jrvidal any news about the internal issue?