Repository navigation
fix: resolve pending discovered deps on close - #23273
Closed
rajanpanth wants to merge 1 commit into
Closed
rajanpanth wants to merge 1 commit into
rajanpanth wants to merge 1 commit into
Conversation
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
Fixes #23143.
When a dependency is discovered before
depsOptimizer.init()runs, Vite intentionally does not start an optimize run yet. If a request for that discovered optimized dep is pending during shutdown, it waits on the dep'sprocessingpromise whileenvironment.close()waits for pending requests to settle. Because no optimize run owns that promise,server.close()can hang.This resolves the active discovered-dep processing promise, plus any queued processing promises, in
depsOptimizer.close(). Pending optimized-dep requests can then settle during shutdown instead of keeping close pending forever.This adapts the same shutdown-path idea from the now-closed #23155 to the current optimizer file layout and adds a regression test beside the existing pre-listen discovery coverage.
Alternatives
Starting an optimize run during close would be more work and would do unnecessary shutdown-time bundling. Resolving the pending processing promises is scoped to teardown and matches the existing closed-path behavior in
runOptimizer().Validation
pnpm run buildpnpm test-unit packages/vite/src/node/__tests__/optimizer/discoverBeforeListen.spec.tspnpm exec oxfmt --check packages/vite/src/node/optimizer/optimizer.ts packages/vite/src/node/__tests__/optimizer/discoverBeforeListen.spec.tspnpm exec eslint packages/vite/src/node/optimizer/optimizer.ts packages/vite/src/node/__tests__/optimizer/discoverBeforeListen.spec.ts --concurrency offpnpm --filter=./packages/vite exec tsc -p src/nodegit diff --check