rabbit_rabbit
rabbit_rabbit5d ago

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.3
36 Replies
veodium
veodium5d ago
Can you show line 22?
rabbit_rabbit
rabbit_rabbitOP5d ago
Thanks for your attention @veodium . It's an import statement
No description
veodium
veodium5d ago
Can you run the code again? still same line?
rabbit_rabbit
rabbit_rabbitOP5d ago
Yes, same line
No description
veodium
veodium4d ago
Could you remove cache or node_modules, deno.lock and run again?
rabbit_rabbit
rabbit_rabbitOP4d ago
Just done, same result. rm -rf node_modules deno cache clear , rm deno.lock deno task start (which runs vite)
No description
veodium
veodium4d ago
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
rabbit_rabbit
rabbit_rabbitOP4d ago
A good thought - sadly I tried again and still got the same result
No description
veodium
veodium4d ago
I think after line 22, the error throwing code is located after 2963 characters (i don't know why deno shows error like this)
rabbit_rabbit
rabbit_rabbitOP4d ago
let me check that…
rabbit_rabbit
rabbit_rabbitOP4d ago
Doesn't appear that's the case
No description
veodium
veodium4d ago
Did you count after line 22?
rabbit_rabbit
rabbit_rabbitOP4d ago
Yes I only copied those lines
veodium
veodium4d ago
Could you ctrl + click(go to the line directly) the line link in the error log?
rabbit_rabbit
rabbit_rabbitOP4d ago
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)
No description
No description
No description
veodium
veodium4d ago
I searched google, and I found sourcemap can be the reason. You may have to add "sourceMap": true in "compilerOptions" in deno.json
rabbit_rabbit
rabbit_rabbitOP4d ago
Looks like it's ignoring that compiler option
No description
veodium
veodium4d ago
Try removing fresh.gen.ts and _fresh folder oh
rabbit_rabbit
rabbit_rabbitOP4d ago
I'm running fresh 2, so no fresh.gen.ts file. Altogether
rm -rf node_modules/ && rm -f deno.lock && rm -rf fresh.gen.ts && rm -rf _fresh && deno task start
Task start ./scripts/dev.sh
Task proxy NO_MONKEY_PATCH_CONSOLE=1 deno task run:trusted proxy.ts
Task run:trusted DENO_TLS_CA_STORE=system deno run -A --unstable-temporal --env --unsafely-ignore-certificate-errors "proxy.ts"
DANGER: TLS certificate validation is disabled for all hostnames
Task vite vite
Unsupported compiler options in "file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/deno.json".
The following options were ignored:
sourceMap

🩺 Virtual Hospitals Africa ready
URL: https://localhost:8000

Unsupported compiler options in "file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/deno.json".
The following options were ignored:
sourceMap

VITE v7.1.12 ready in 2978 ms

➜ Local: http://localhost:8001/
➜ Network: use --host to expose
WARN RS - Unsupported compiler options in "file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/deno.json".
The following options were ignored:
sourceMap
Error: no bueno
at TriageBriefHistoryPage (/Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/routes/app/organizations/[organization_id]/patients/[patient_id]/open_encounter/triage/brief_history.tsx:22:2963)
rm -rf node_modules/ && rm -f deno.lock && rm -rf fresh.gen.ts && rm -rf _fresh && deno task start
Task start ./scripts/dev.sh
Task proxy NO_MONKEY_PATCH_CONSOLE=1 deno task run:trusted proxy.ts
Task run:trusted DENO_TLS_CA_STORE=system deno run -A --unstable-temporal --env --unsafely-ignore-certificate-errors "proxy.ts"
DANGER: TLS certificate validation is disabled for all hostnames
Task vite vite
Unsupported compiler options in "file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/deno.json".
The following options were ignored:
sourceMap

🩺 Virtual Hospitals Africa ready
URL: https://localhost:8000

Unsupported compiler options in "file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/deno.json".
The following options were ignored:
sourceMap

VITE v7.1.12 ready in 2978 ms

➜ Local: http://localhost:8001/
➜ Network: use --host to expose
WARN RS - Unsupported compiler options in "file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/deno.json".
The following options were ignored:
sourceMap
Error: no bueno
at TriageBriefHistoryPage (/Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/routes/app/organizations/[organization_id]/patients/[patient_id]/open_encounter/triage/brief_history.tsx:22:2963)
veodium
veodium4d ago
I think I found the solution
rabbit_rabbit
rabbit_rabbitOP4d ago
do tell!
veodium
veodium4d ago
https://github.com/vitejs/vite/issues/5834 do not use multi line imports try using single line import
rabbit_rabbit
rabbit_rabbitOP4d ago
I will try that in this file
veodium
veodium4d ago
ok
rabbit_rabbit
rabbit_rabbitOP4d ago
very interesting!
rabbit_rabbit
rabbit_rabbitOP4d ago
Hm, so it gives the same exact line number as before.
No description
No description
rabbit_rabbit
rabbit_rabbitOP4d ago
That does seem like a good lead
veodium
veodium4d ago
😭
rabbit_rabbit
rabbit_rabbitOP4d ago
certainly related thematically (vite + line numbers) to what we're seeing
veodium
veodium4d ago
https://github.com/vitejs/vite/issues/9825
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [
{
name: 'remove-sourcemaps',
transform(code) {
return {
code,
map: { mappings: '' }
}
}
}
]
})
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [
{
name: 'remove-sourcemaps',
transform(code) {
return {
code,
map: { mappings: '' }
}
}
}
]
})
try adding remove-sourcemaps plugin code
rabbit_rabbit
rabbit_rabbitOP4d ago
I really appreciate the help. It looks like this trades one problem for another. Now everything is an unmapped anonymous function
Error: no bueno
at TriageBriefHistoryPage (eval at runInlinedModule (file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/node_modules/.deno/vite@7.1.12/node_modules/vite/dist/node/module-runner.js:905:9), <anonymous>:22:2963)
at eval (eval at runInlinedModule (file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/node_modules/.deno/vite@7.1.12/node_modules/vite/dist/node/module-runner.js:905:9), <anonymous>:44:915)
at eval (eval at runInlinedModule (file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/node_modules/.deno/vite@7.1.12/node_modules/vite/dist/node/module-runner.js:905:9), <anonymous>:9:338)
at NoopContextManager.with (eval at runInlinedModule (file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/node_modules/.deno/vite@7.1.12/node_modules/vite/dist/node/module-runner.js:905:9), <anonymous>:22:480)
at ContextAPI.with (eval at runInlinedModule (file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/node_modules/.deno/vite@7.1.12/node_modules/vite/dist/node/module-runner.js:905:9), <anonymous>:39:78)
Error: no bueno
at TriageBriefHistoryPage (eval at runInlinedModule (file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/node_modules/.deno/vite@7.1.12/node_modules/vite/dist/node/module-runner.js:905:9), <anonymous>:22:2963)
at eval (eval at runInlinedModule (file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/node_modules/.deno/vite@7.1.12/node_modules/vite/dist/node/module-runner.js:905:9), <anonymous>:44:915)
at eval (eval at runInlinedModule (file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/node_modules/.deno/vite@7.1.12/node_modules/vite/dist/node/module-runner.js:905:9), <anonymous>:9:338)
at NoopContextManager.with (eval at runInlinedModule (file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/node_modules/.deno/vite@7.1.12/node_modules/vite/dist/node/module-runner.js:905:9), <anonymous>:22:480)
at ContextAPI.with (eval at runInlinedModule (file:///Users/willweiss/dev/morehumaninternet/virtual-hospitals-africa/node_modules/.deno/vite@7.1.12/node_modules/vite/dist/node/module-runner.js:905:9), <anonymous>:39:78)
veodium
veodium4d ago
Still I can see 22:2963..... the plugin solution seems not working 🙁 May be Gemini CLI will help better than me
rabbit_rabbit
rabbit_rabbitOP4d ago
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
rabbit_rabbit
rabbit_rabbitOP4d ago
@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 ...
veodium
veodium4d ago
vite 7 is too new. so try using vite 6
deno add npm:vite@6
deno add npm:vite@6
If it works, its obviously vite problem
rabbit_rabbit
rabbit_rabbitOP4d ago
Hm, that doesn't seem to work
[ERR_UNSUPPORTED_ESM_URL_SCHEME] Only file and data URLs are supported by the default ESM loader. Received protocol 'npm'
at async SSRCompatModuleRunner.directRequest (/Users/willweiss/dev/morehumaninternet/vite-fresh-linenumber-repro/node_modules/.deno/vite@6.4.1/node_modules/vite/dist/node/module-runner.js:1233:24)
at async SSRCompatModuleRunner.cachedRequest (/Users/willweiss/dev/morehumaninternet/vite-fresh-linenumber-repro/node_modules/.deno/vite@6.4.1/node_modules/vite/dist/node/module-runner.js:1180:76)
at async eval (deno::0::https:/jsr.io/@fresh/core/2.1.4/src/app.ts:7:31)
at async ESModulesEvaluator.runInlinedModule (/Users/willweiss/dev/morehumaninternet/vite-fresh-linenumber-repro/node_modules/.deno/vite@6.4.1/node_modules/vite/dist/node/module-runner.js:1062:5)
at async SSRCompatModuleRunner.directRequest (/Users/willweiss/dev/morehumaninternet/vite-fresh-linenumber-repro/node_modules/.deno/vite@6.4.1/node_modules/vite/dist/node/module-runner.js:1284:61)
at async SSRCompatModuleRunner.directRequest (/Users/willweiss/dev/morehumaninternet/vite-fresh-linenumber-repro/node_modules/.deno/vite@6.4.1/node_modules/vite/dist/node/chunks/dep-D4NMHUTW.js:25274:23)
at async SSRCompatModuleRunner.cachedRequest (/Users/willweiss/dev/morehumaninternet/vite-fresh-linenumber-repro/node_modules/.deno/vite@6.4.1/node_modules/vite/dist/node/module-runner.js:1180:76)
at async eval (deno::0::https:/jsr.io/@fresh/core/2.1.4/src/internals.ts:8:148)
[ERR_UNSUPPORTED_ESM_URL_SCHEME] Only file and data URLs are supported by the default ESM loader. Received protocol 'npm'
at async SSRCompatModuleRunner.directRequest (/Users/willweiss/dev/morehumaninternet/vite-fresh-linenumber-repro/node_modules/.deno/vite@6.4.1/node_modules/vite/dist/node/module-runner.js:1233:24)
at async SSRCompatModuleRunner.cachedRequest (/Users/willweiss/dev/morehumaninternet/vite-fresh-linenumber-repro/node_modules/.deno/vite@6.4.1/node_modules/vite/dist/node/module-runner.js:1180:76)
at async eval (deno::0::https:/jsr.io/@fresh/core/2.1.4/src/app.ts:7:31)
at async ESModulesEvaluator.runInlinedModule (/Users/willweiss/dev/morehumaninternet/vite-fresh-linenumber-repro/node_modules/.deno/vite@6.4.1/node_modules/vite/dist/node/module-runner.js:1062:5)
at async SSRCompatModuleRunner.directRequest (/Users/willweiss/dev/morehumaninternet/vite-fresh-linenumber-repro/node_modules/.deno/vite@6.4.1/node_modules/vite/dist/node/module-runner.js:1284:61)
at async SSRCompatModuleRunner.directRequest (/Users/willweiss/dev/morehumaninternet/vite-fresh-linenumber-repro/node_modules/.deno/vite@6.4.1/node_modules/vite/dist/node/chunks/dep-D4NMHUTW.js:25274:23)
at async SSRCompatModuleRunner.cachedRequest (/Users/willweiss/dev/morehumaninternet/vite-fresh-linenumber-repro/node_modules/.deno/vite@6.4.1/node_modules/vite/dist/node/module-runner.js:1180:76)
at async eval (deno::0::https:/jsr.io/@fresh/core/2.1.4/src/internals.ts:8:148)

Did you find this page helpful?