Skip to content

fix(@angular/build): keep Vite server file watcher disabled in Vitest watch mode - #34319

Merged
dgp1130 merged 1 commit into
angular:mainfrom
clydin:fix/vitest-disable-server-watch
Oct 12, 2026
Merged

dgp1130 merged 1 commit into
angular:mainfrom
clydin:fix/vitest-disable-server-watch

Conversation

@clydin

@clydin clydin commented Oct 12, 2026

Copy link
Copy Markdown
Member

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.

… 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.
@clydin clydin added the target: patch This PR is targeted for the next patch release label Oct 12, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Oct 12, 2026
@clydin
clydin requested a review from alan-agius4 October 12, 2026 15:05
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 12, 2026
@dgp1130
dgp1130 merged commit 39d230e into angular:main Oct 12, 2026
42 of 43 checks passed
@dgp1130

dgp1130 commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

@clydin
clydin deleted the fix/vitest-disable-server-watch branch October 12, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants