Skip to content

Commit

Permalink
fix(optimizer): suppress esbuild cancel error (#12358)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Mar 10, 2023
1 parent 6b40f03 commit 86a24e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,14 @@ export function runOptimizeDeps(

return createProcessingResult()
})
.catch((e) => {
if (e.errors && e.message.includes('The build was canceled')) {
// esbuild logs an error when cancelling, but this is expected so
// return an empty result instead
return createProcessingResult()
}
throw e
})
.finally(() => {
return disposeContext()
})
Expand Down
6 changes: 6 additions & 0 deletions packages/vite/src/node/optimizer/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ export function scanImports(config: ResolvedConfig): {
})
})
.catch(async (e) => {
if (e.errors && e.message.includes('The build was canceled')) {
// esbuild logs an error when cancelling, but this is expected so
// return an empty result instead
return { deps: {}, missing: {} }
}

const prependMessage = colors.red(`\
Failed to scan for dependencies from entries:
${entries.join('\n')}
Expand Down

0 comments on commit 86a24e4

Please sign in to comment.