Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/breezy-onions-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix error stacktrace from Vite SSR runtime
2 changes: 1 addition & 1 deletion packages/astro/src/vite-plugin-astro-postprocess/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function astro(_opts: AstroPluginOptions): Plugin {
if (s) {
return {
code: s.toString(),
map: s.generateMap(),
map: s.generateMap({ hires: true }),
};
}
},
Expand Down
6 changes: 6 additions & 0 deletions packages/astro/src/vite-plugin-astro-server/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ export async function handleRequest(
},
onError(_err) {
const err = createSafeError(_err);

// This could be a runtime error from Vite's SSR module, so try to fix it here
try {
env.loader.fixStacktrace(err as Error);
} catch {}

// This is our last line of defense regarding errors where we still might have some information about the request
// Our error should already be complete, but let's try to add a bit more through some guesswork
const errorWithMetadata = collectErrorMetadata(err, config.root);
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/vite-plugin-env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default function envVitePlugin({ settings }: EnvPluginOptions): vite.Plug
if (s) {
return {
code: s.toString(),
map: s.generateMap(),
map: s.generateMap({ hires: true }),
};
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/vite-plugin-scripts/page-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function astroScriptsPostPlugin({

return {
code: s.toString(),
map: s.generateMap(),
map: s.generateMap({ hires: true }),
};
},
};
Expand Down