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

Wrong stack traces in dev mode #119

Open
dennisameling opened this issue Jan 31, 2025 · 0 comments · May be fixed by #120
Open

Wrong stack traces in dev mode #119

dennisameling opened this issue Jan 31, 2025 · 0 comments · May be fixed by #120

Comments

@dennisameling
Copy link

When running in dev mode, vite-plugin-node creates incorrect stack traces. The line numbers are wrongly referenced.

Reproducer

Here's a minimal reproducer: https://github.com/dennisameling/vite-plugin-node-stack-bug

When running that reproducer with npm run dev, then going to http://localhost:3000, it triggers the stack trace. You can see that it references line 8 (example below), while the actual error is triggered on line 10.

Error: This error produces a stack trace that is incorrect.
    at eval (/Users/dennisameling/repos/vite-plugin-node-stack-bug/src/server.ts:8:9)
    at Layer.handle [as handle_request] (/Users/dennisameling/repos/vite-plugin-node-stack-bug/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/dennisameling/repos/vite-plugin-node-stack-bug/node_modules/express/lib/router/route.js:149:13)
    at Route.dispatch (/Users/dennisameling/repos/vite-plugin-node-stack-bug/node_modules/express/lib/router/route.js:119:3)
    at Layer.handle [as handle_request] (/Users/dennisameling/repos/vite-plugin-node-stack-bug/node_modules/express/lib/router/layer.js:95:5)
    at /Users/dennisameling/repos/vite-plugin-node-stack-bug/node_modules/express/lib/router/index.js:284:15
    at Function.process_params (/Users/dennisameling/repos/vite-plugin-node-stack-bug/node_modules/express/lib/router/index.js:346:12)
    at next (/Users/dennisameling/repos/vite-plugin-node-stack-bug/node_modules/express/lib/router/index.js:280:10)
    at expressInit (/Users/dennisameling/repos/vite-plugin-node-stack-bug/node_modules/express/lib/middleware/init.js:40:5)
    at Layer.handle [as handle_request] (/Users/dennisameling/repos/vite-plugin-node-stack-bug/node_modules/express/lib/router/layer.js:95:5)

Potential solution

ViteDevServer has a method called ssrFixStacktrace to fix stack traces.

I'll file a PR with a fix for at least Express.

@dennisameling dennisameling linked a pull request Jan 31, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant