fix(watch): warn when the project root matches a default ignore glob - #23529
Closed
nikolas-sapa wants to merge 1 commit into
Closed
nikolas-sapa wants to merge 1 commit into
nikolas-sapa wants to merge 1 commit into
Conversation
resolveChokidarOptions prepends hardcoded default ignore globs (**/.git/**, **/node_modules/**, **/test-results/**) ahead of every user entry. When the project root itself lives under an ancestor path segment matching one of these (e.g. staged under a test-results/ directory), chokidar watches zero project directories: no HMR, no module invalidation, no error surface — the failure looks like a downstream caching bug and is very hard to diagnose. anymatch's ANY-match semantics mean no user server.watch.ignored entry can re-include the files either. Warn when the root matches one of the default globs so the dead watcher is diagnosable. Only the hardcoded defaults are checked — a user's own ignore matching the root is their choice, not a surprise. Fixes vitejs#23523
Contributor
|
This PR has been automatically flagged as likely to be created by a bot, LLM, or agent, and will be automatically closed. These contributions harm the maintenance of the project. Please read our AI policy for more information. If you believe this is a mistake, please reply to this comment and we will review it. |
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.
Fixes #23523.
Problem
resolveChokidarOptionsprepends hardcoded default ignore globs —**/.git/**,**/node_modules/**,**/test-results/**(Playwright) — ahead of every user entry. Those globs are meant for tooling output inside a project, but they are anchored with**/, so they also match when the project root itself lives under an ancestor path segment of that name.When that happens (e.g. a harness stages project copies inside a gitignored
test-results/directory — exactly what the glob exists to ignore), chokidar watches zero project directories: file edits fire no events, the module graph never invalidates, HMR never emits, and a full reload keeps serving pre-edit modules. There is no error surface — the failure looks like a downstream caching bug. And because anymatch ignores a path when any pattern matches, noserver.watch.ignoredentry can re-include the files.The issue reporter confirmed
watcher.getWatched()returns 0 directories over such a root, and that moving the project one directory up makes the watcher see everything again.Change
Warn when the resolved project root matches one of the hardcoded default ignore globs, so a dead watcher is diagnosable instead of silent:
Only the built-in defaults are checked — a user's own
server.watch.ignoredmatching the root is their explicit choice, not a surprise, so it does not warn (there's a test for that). This is the lower-risk half of the reporter's suggestion (b); making the defaults removable (a) would be a larger API change and can be a follow-up.Tests
Three cases in
watcher.spec.ts: warns for a root undertest-results/, does not warn for a normal root, and does not warn when only a user-supplied ignore matches the root. Reverting the source change turns the first test red while the two negative tests stay green. Fullwatcher.spec.tspasses (including the existing real-server watch tests).