Skip to content

Commit

Permalink
fix: unhandled exception on eager transformRequest (#7345)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Mar 16, 2022
1 parent 61df324 commit c3260a4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/vite/src/node/plugins/importAnalysis.ts
Expand Up @@ -37,6 +37,7 @@ import {
VALID_ID_PREFIX,
NULL_BYTE_PLACEHOLDER
} from '../constants'
import { ERR_OUTDATED_OPTIMIZED_DEP } from './optimizedDeps'
import type { ViteDevServer } from '..'
import { checkPublicFile } from './asset'
import { parse as parseJS } from 'acorn'
Expand Down Expand Up @@ -630,7 +631,14 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
NULL_BYTE_PLACEHOLDER,
'\0'
)
transformRequest(url, server, { ssr })
transformRequest(url, server, { ssr }).catch((e) => {
if (e?.code === ERR_OUTDATED_OPTIMIZED_DEP) {
// This are expected errors
return
}
// Unexpected error, log the issue but avoid an unhandled exception
config.logger.error(e.message)
})
})
}

Expand Down

0 comments on commit c3260a4

Please sign in to comment.