Skip to content

Commit

Permalink
fix(ssr): avoid rewriting error.message for "Server is closed" error
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jan 3, 2022
1 parent 29a4496 commit 297937e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/vite/src/node/ssr/ssrModuleLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const isDebug = !!process.env.DEBUG
const debug = createDebugger('vite:ssr')
const warn = (...msg: string[]) => debug(chalk.yellow('warn ') + msg.join(' '))

const E_SERVER_CLOSED = 'Server is closed'

export type SSRModuleExports = Record<string, any>

export interface SSRModule {
Expand Down Expand Up @@ -199,7 +201,7 @@ export async function ssrLoadModule(
urlStack: string[] = []
): Promise<SSRModuleExports | SSRModuleExports[]> {
if (server.closed) {
throw Error('Server is closed')
throw Error(E_SERVER_CLOSED)
}
if (Array.isArray(url)) {
// Load multiple entries in parallel.
Expand Down Expand Up @@ -237,7 +239,7 @@ export async function ssrLoadModule(
))
)
executing.catch((e) => {
if (!e.originalStack) {
if (!e.originalStack && e.message !== E_SERVER_CLOSED) {
try {
ssrRewriteStacktrace(e, server.moduleGraph)
} catch {}
Expand Down

0 comments on commit 297937e

Please sign in to comment.