Repository navigation
fix(@angular/build): keep Vite server file watcher disabled in Vitest watch mode - #34319
Merged
Merged
Conversation
… watch mode
In Vitest 5, the internal `vitest:config:append` plugin uses a post
`configResolved` hook that resets `server.watch` to `{}` when watch mode
is enabled (`server.watch ??= {}`), overriding the `server: { watch: null }`
setting passed in `vitestServerConfig`. This caused Vite to start a
duplicate Chokidar file watcher alongside the Angular CLI build watcher
and trigger redundant, racing test reruns on file changes.
Enforce `post` ordering on `angular:vitest-configuration` and reset
`config.server.watch = null` in a post `configResolved` hook so Vite
uses its no-op watcher.
There was a problem hiding this comment.
Code Review
This pull request moves the logic for disabling the Vite server file watcher from the executor configuration to a post-enforced configResolved hook in the Vitest configuration plugin, ensuring Vitest's internal hooks do not reset server.watch. A test case was also added to verify this behavior. However, a critical issue was identified in the configResolved hook implementation: Vite does not support the object form (with order and handler) for configResolved, which would cause a runtime TypeError. It is recommended to change it to a standard function hook.
alan-agius4
approved these changes
Oct 12, 2026
Collaborator
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.
In Vitest 5, the internal
vitest:config:appendplugin uses a postconfigResolvedhook that resetsserver.watchto{}when watch mode is enabled (server.watch ??= {}), overriding theserver: { watch: null }setting passed invitestServerConfig. This caused Vite to start a duplicate Chokidar file watcher alongside the Angular CLI build watcher and trigger redundant, racing test reruns on file changes.Enforce
postordering onangular:vitest-configurationand resetconfig.server.watch = nullin a postconfigResolvedhook so Vite uses its no-op watcher.