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

fix(ssr): show ssr module loader error stack #12651

Merged
merged 6 commits into from Mar 31, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/vite/src/node/ssr/ssrModuleLoader.ts
Expand Up @@ -147,7 +147,10 @@ async function instantiateModule(
context,
urlStack,
fixStacktrace,
)
).catch((err) => {
err.importee = dep
throw err
})
bluwy marked this conversation as resolved.
Show resolved Hide resolved
if (pendingDeps.length === 1) {
pendingImports.delete(url)
} else {
Expand Down Expand Up @@ -212,7 +215,8 @@ async function instantiateModule(
server.config.logger.error(
colors.red(
`Error when evaluating SSR module ${url}:` +
(e.importee ? ` failed to import "${e.importee}"\n` : '\n'),
(e.importee ? ` failed to import "${e.importee}"` : '') +
`\n|- ${e.stack}\n`,
),
{
timestamp: true,
Expand All @@ -221,7 +225,6 @@ async function instantiateModule(
},
)

delete e.importee
bluwy marked this conversation as resolved.
Show resolved Hide resolved
throw e
}

Expand Down