Description
Describe the bug
While upgrading Vite from 5.1.0 to 5.1.6 on my monorepo with vite-node-miniflare hi-ogawa/vite-plugins#198, I found my tests which asserts stacktrace are failing. On further investigation, there seems to be a subtle difference since 5.1.5 as seen in this simpler reproduction.
node run.mjs ./repro-entry.ts
...
Error: crash ssr
at crash (.../repro-entry.ts:2:9)
at main (.../repro-entry.ts:6:9) <---- 6:3 became 6:9 since 5.1.5
function crash(message) {
throw new Error(message);
}
function main() {
crash("crash ssr");
//^ 6:3 <- before
// ^ 6:9 <- after
}
main();
On my actual case, I use a plugin vitePluginSimpleHmr
which adds one more transform to ssr code, then stacktrace seems more broken (not only column, but also line and absolute path resolution is not working). For this part, there might be an issue with my plugin, so I'm not sure whether it's related to Vite side change and I haven't tried minimal repro for that yet.
Reproduction
https://github.com/hi-ogawa/reproductions/tree/main/vite-runtime-stacktrace-5.1.5
Steps to reproduce
In the reproduction, I added a comparison with node and also when vite entry is plain javascript, in which case there's no difference in stacktrace.
Stackblitz doesn't seem to have a good support on stacktrace, so it might be necessary to copy the reproduction locally. To skip cloning the entire repo, you can use tools such as https://github.com/tiged/tiged
npx tiged hi-ogawa/reproductions/vite-runtime-stacktrace-5.1.5 repro
System Info
System:
OS: Linux 6.7 Arch Linux
CPU: (12) x64 AMD Ryzen 5 5625U with Radeon Graphics
Memory: 9.30 GB / 14.98 GB
Container: Yes
Shell: 5.2.26 - /bin/bash
Binaries:
Node: 20.11.1 - ~/.volta/tools/image/node/20.11.1/bin/node
Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
npm: 10.2.4 - ~/.volta/tools/image/node/20.11.1/bin/npm
pnpm: 8.12.0 - ~/.volta/bin/pnpm
bun: 1.0.26 - ~/.volta/bin/bun
Browsers:
Chromium: 122.0.6261.111
npmPackages:
vite: 5.1.5 => 5.1.5
Used Package Manager
npm
Logs
This is the same content as reproduction readme, but just in case:
# node
node ./repro-entry.mjs
...
Error: crash ssr
at crash (.../repro-entry.mjs:2:9)
at main (.../repro-entry.mjs:6:3)
...
# vite + js
node run.mjs ./repro-entry.mjs
...
Error: crash ssr
at crash (.../repro-entry.mjs:2:9)
at main (.../repro-entry.mjs:6:3)
...
# vite 5.1.4 + ts
node run.mjs ./repro-entry.ts
...
Error: crash ssr
at crash (.../repro-entry.ts:2:9)
at main (.../repro-entry.ts:6:3)
...
# vite 5.1.5 + ts
node run.mjs ./repro-entry.ts
...
Error: crash ssr
at crash (.../repro-entry.ts:2:9)
at main (.../repro-entry.ts:6:9) <---- 6:3 became 6:9
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.