Fix error stacktrace from Vite SSR runtime (#7273)
This commit is contained in:
parent
83016795e9
commit
6dfd7081b7
5 changed files with 14 additions and 3 deletions
5
.changeset/breezy-onions-scream.md
Normal file
5
.changeset/breezy-onions-scream.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix error stacktrace from Vite SSR runtime
|
|
@ -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 }),
|
||||
};
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 }),
|
||||
};
|
||||
}
|
||||
},
|
||||
|
|
|
@ -35,7 +35,7 @@ export default function astroScriptsPostPlugin({
|
|||
|
||||
return {
|
||||
code: s.toString(),
|
||||
map: s.generateMap(),
|
||||
map: s.generateMap({ hires: true }),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue