Error stack trace giving incorrect line number (possibly related to async eval?)
In a handler for a Fresh application I noticed that assertion errors were giving the wrong line number. Throwing an error gives a line number of 22 in the attached error message. However, the actual error is being thrown on line 162.
deno.json and deno.lock attached. Any idea what might be causing this? Thanks!
```deno --version
deno 2.3.5 (stable, release, aarch64-apple-darwin)
v8 13.7.152.6-rusty
typescript 5.8.336 Replies
Can you show line 22?
Thanks for your attention @veodium . It's an import statement

Can you run the code again?
still same line?
Yes, same line

Could you remove cache or node_modules, deno.lock and run again?
Just done, same result.
rm -rf node_modules deno cache clear , rm deno.lock deno task start (which runs vite)
I think _fresh folder(if it exists) is the problem. Could you remove it and run again?
I had similar problem with _fresh folder. After removing it it worked well
A good thought - sadly I tried again and still got the same result

I think after line 22, the error throwing code is located after 2963 characters (i don't know why deno shows error like this)
let me check that…
Doesn't appear that's the case

Did you count after line 22?
Yes I only copied those lines
Could you ctrl + click(go to the line directly) the line link in the error log?
It goes to this import line. That function is called elsewhere and isn't relevant. To confirm that I commented out that line (in the separate POST handler) and now the error is shown to be at line 17 (images 2 & 3)



I searched google, and I found sourcemap can be the reason.
You may have to add "sourceMap": true in "compilerOptions" in deno.json
Looks like it's ignoring that compiler option

Try removing fresh.gen.ts and _fresh folder
oh
I'm running fresh 2, so no fresh.gen.ts file. Altogether
I think I found the solution
do tell!
https://github.com/vitejs/vite/issues/5834
do not use multi line imports
try using single line import
I will try that in this file
ok
very interesting!
Hm, so it gives the same exact line number as before.


That does seem like a good lead
😭
certainly related thematically (vite + line numbers) to what we're seeing
I really appreciate the help. It looks like this trades one problem for another. Now everything is an unmapped anonymous function
Still I can see 22:2963.....
the plugin solution seems not working 🙁
May be Gemini CLI will help better than me
I put together a minimal repro
GitHub
GitHub - will-weiss/vite-fresh-linenumber-repro: minimal reproducti...
minimal reproduction of incorrect line numbers in a Fresh 2/Vite project - will-weiss/vite-fresh-linenumber-repro
@veodium thanks so much for your help! I filed an issue here. https://github.com/vitejs/vite/issues/21080
The spot of the line numbers being exactly the same with/without sourcemaps I think will be a big clue for whoever picks up this bug.
GitHub
Line numbers in stack traces incorrect · Issue #21080 · vitejs/vite
Describe the bug I am running a vanilla Fresh 2 project that bundles using vite. In it, errors in stack traces have the wrong line number. Interestingly the line/column numbers can be seen exactly ...
vite 7 is too new. so try using vite 6
If it works, its obviously vite problem
Hm, that doesn't seem to work
