Skip to content

fix: watch future glob matches without mutating options - #5731

Open
OskarEichler wants to merge 1 commit into
webpack:mainfrom
OskarEichler:codex/glob-watch-lifecycle
Open

fix: watch future glob matches without mutating options#5731
OskarEichler wants to merge 1 commit into
webpack:mainfrom
OskarEichler:codex/glob-watch-lifecycle

Conversation

@OskarEichler

@OskarEichler OskarEichler commented Aug 28, 2026

Copy link
Copy Markdown

Fixes

  • Watch each glob's static parent and filter file registrations, so future matching files/directories remain discoverable.
  • Match ignored globs against future paths, preserving function, regex and matcher-object ignores.
  • Keep explicit paths in mixed arrays and apply negative patterns as exclusions.
  • Clone watch options instead of mutating ignored; frozen options are supported.
  • Remove synchronous filesystem glob expansion from watch setup and deduplicate watched roots.

Compatibility

No API/engine removal. Adds picomatch ^4.0.4 as a direct dependency (already present transitively in the lockfile). Relative patterns remain cwd-relative; events retain chokidar's cwd semantics. Newly created matches now trigger live reload when subsequently edited. Directory watching is necessary to discover future matches; nonmatching files are excluded.

Verification

All 32 unchanged upstream watch-files tests pass. Ten real filesystem scenarios pass: absolute/cwd paths, negative patterns, function/regex/object ignores, mixed literal/glob paths, missing roots, escaped bracket paths and frozen options. Original source reproduces missed new files and option mutation. Build and full lint/types/formatting/spelling pass. Windows filesystem execution remains unverified.

Audit scope

This is a focused, independently based change from a broader source review at f804962. The combined frozen-source run executed 1,002 tests: 951 passed, 43 failed, one cancelled, seven skipped. Failures were traced to the separately proposed overlay DOM snapshots, reconnect-disabled test expectation and IPv6 host-test assumptions; it is not represented as a green full suite. Relevant focused results are listed above. No checked-in tests/specs/snapshots were added or modified. Hosted CI and the full OS/Node matrix remain pending.

Summary by CodeRabbit

  • Bug Fixes
    • File watching now detects new files created after startup when they match configured glob patterns.
    • Ignored glob patterns continue to apply to future files.
    • Watch options are preserved without being modified during processing.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c619d8e4-f366-44ff-afcb-6c0b7a178c66

📥 Commits

Reviewing files that changed from the base of the PR and between f804962 and 1af4288.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • .changeset/watch-future-glob-matches.md
  • lib/Server.js
  • package.json

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


Walkthrough

Server.watchFiles now passes watch roots to chokidar instead of eagerly expanding glob patterns. It classifies dynamic, negated, and literal paths, uses picomatch for glob matching, and filters unrelated files during traversal. Ignored string globs are also matched dynamically without mutating the supplied watch options. A patch changeset and the picomatch runtime dependency were added.

Merge Risk: 🔵 Low · up to 1af42

The change enables future glob matches while preserving filtering and frozen options, but configured broad or externally writable directories may increase filesystem traversal and watcher resource use. The PR is mergeable with explicit owner awareness of this bounded operational risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: watching future glob matches without mutating watch options.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

lib/Server.js

ESLint failed to execute (timeout).

package.json

ESLint skipped: the matched ESLint configuration already failed (timeout).


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread package.json
"launch-editor": "^2.14.1",
"open": "^11.0.0",
"p-retry": "^8.0.0",
"picomatch": "^4.0.4",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should avoid extra packages here

@alexander-akait alexander-akait left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't need multiple glob related packages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants