From 4a72e08a295af1ae2f827e9c1dc7b382a05edbfd Mon Sep 17 00:00:00 2001 From: sapphi-red <49056869+sapphi-red@users.noreply.github.com> Date: Fri, 22 Nov 2024 20:15:40 +0900 Subject: [PATCH] fix: optimizer stall --- packages/vite/src/node/optimizer/optimizer.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/optimizer/optimizer.ts b/packages/vite/src/node/optimizer/optimizer.ts index a0a526b4a61685..8349e914dfe6c9 100644 --- a/packages/vite/src/node/optimizer/optimizer.ts +++ b/packages/vite/src/node/optimizer/optimizer.ts @@ -162,7 +162,6 @@ export function createDepsOptimizer( cachedMetadata || initDepsOptimizerMetadata(environment, sessionTimestamp) if (!cachedMetadata) { - environment.waitForRequestsIdle().then(onCrawlEnd) waitingForCrawlEnd = true // Enter processing state until crawl of static imports ends @@ -187,6 +186,8 @@ export function createDepsOptimizer( newDepsDiscovered = true } + environment.waitForRequestsIdle().then(onCrawlEnd) + if (noDiscovery) { // We don't need to scan for dependencies or wait for the static crawl to end // Run the first optimization run immediately