Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(optimizer): suppress esbuild cancel error #12358

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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