Skip to content

Commit

Permalink
fix(optimizer): avoid race condition when discovery is disabled
Browse files Browse the repository at this point in the history
When configured with `noDiscovery: true`, the optimizer needs to wait until the initial static optimize step finishes before processing subsequent requests.
  • Loading branch information
kherock committed Jul 15, 2023
1 parent 45c6f3b commit da089ad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/vite/src/node/optimizer/optimizer.ts
Expand Up @@ -220,7 +220,8 @@ async function createDepsOptimizer(
if (config.optimizeDeps.noDiscovery) {
// We don't need to scan for dependencies or wait for the static crawl to end
// Run the first optimization run immediately
runOptimizer()
const knownDeps = prepareKnownDeps()
optimizationResult = runOptimizeDeps(config, knownDeps)
} else if (!isBuild) {
// Important, the scanner is dev only
depsOptimizer.scanProcessing = new Promise((resolve) => {
Expand Down

0 comments on commit da089ad

Please sign in to comment.