Repository navigation
fix(optimizer): resolve pending discovered dep processing on close before init (fix #23143) - #23155
Closed
santhiprakash wants to merge 1 commit into
Closed
santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
…fore init (fix #23143) When a dependency is discovered through the JS API before `depsOptimizer.init()` runs (i.e. before `server.listen()`), the dep's `processing` promise is never resolved because `registerMissingImport()` only kicks off an optimize run when `initState === 'initialized'`. Any in-flight request awaiting that processing promise then blocks `DevEnvironment.close()`'s pending-request loop, causing `server.close()` to hang forever. Resolve the current `depOptimizationProcessing` promise and any queued processing promises in `depsOptimizer.close()`, mirroring the safety net already used in `runOptimizer()`'s closed branches.
Contributor
Author
|
Closing: the source files modified by this PR have been removed or reorganized on upstream/main following a repo restructuring. The patch no longer applies. |
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a dependency is discovered through the JS API before
depsOptimizer.init()runs (i.e. beforeserver.listen()), the dep'sprocessingpromise is never resolved becauseregisterMissingImport()only starts an optimize run wheninitState === 'initialized'. Any in-flight request awaiting that processing promise then blocksDevEnvironment.close()'s pending-request loop, causingserver.close()to hang forever.This PR resolves the current
depOptimizationProcessingpromise and any queued processing promises indepsOptimizer.close(), mirroring the safety net already used inrunOptimizer()'s closed branches. This unblocks in-flight requests during shutdown.fixes #23143
Alternatives
Test plan
packages/vite/src/node/__tests__/optimizer/discoverBeforeListen.spec.tsthat discovers a dep beforeinit()and assertsdepsOptimizer.close()resolves its pendingprocessingpromise.pnpm test-unit packages/vite/src/node/__tests__/optimizer/discoverBeforeListen.spec.tspasses.pnpm --filter=./packages/vite exec tsc -p src/nodepasses.