Closed sapphi-red closed 8 hours ago
When the optimizer runs before manual included deps are registered, Vite indefinitely stalled the request to optimized files.
I guess this rarely happens. It happens when runOptimizer in this onCrawlEnd is called while the promise of addManuallyIncludedOptimizeDeps(environment, manuallyIncludedDeps) is pending. https://github.com/vitejs/vite/blob/a384d8fd39162190675abcfea31ba657383a3d03/packages/vite/src/node/optimizer/optimizer.ts#L165 https://github.com/vitejs/vite/blob/a384d8fd39162190675abcfea31ba657383a3d03/packages/vite/src/node/optimizer/optimizer.ts#L174
runOptimizer
onCrawlEnd
addManuallyIncludedOptimizeDeps(environment, manuallyIncludedDeps)
Changing the code like below would make it constantly reproduce the problem with react template of create-vite.
- environment.waitForRequestsIdle().then(onCrawlEnd) + // environment.waitForRequestsIdle().then(onCrawlEnd) waitingForCrawlEnd = true // Enter processing state until crawl of static imports ends currentlyProcessing = true // Initialize discovered deps with manually added optimizeDeps.include info const manuallyIncludedDeps: Record<string, string> = {} await addManuallyIncludedOptimizeDeps(environment, manuallyIncludedDeps) + startNextDiscoveredBatch() + await runOptimizer() const manuallyIncludedDepsInfo = toDiscoveredDependencies( environment, manuallyIncludedDeps, sessionTimestamp, )
Description
When the optimizer runs before manual included deps are registered, Vite indefinitely stalled the request to optimized files.
I guess this rarely happens. It happens when
runOptimizer
in thisonCrawlEnd
is called while the promise ofaddManuallyIncludedOptimizeDeps(environment, manuallyIncludedDeps)
is pending. https://github.com/vitejs/vite/blob/a384d8fd39162190675abcfea31ba657383a3d03/packages/vite/src/node/optimizer/optimizer.ts#L165 https://github.com/vitejs/vite/blob/a384d8fd39162190675abcfea31ba657383a3d03/packages/vite/src/node/optimizer/optimizer.ts#L174Changing the code like below would make it constantly reproduce the problem with react template of create-vite.