Skip to content

refactor(@angular/build): guard closed chokidar operations and remove v5 unlink workaround - #34471

Merged
clydin merged 1 commit into
angular:mainfrom
clydin:refactor/chokidar-v6-followup
Oct 22, 2026
Merged

clydin merged 1 commit into
angular:mainfrom
clydin:refactor/chokidar-v6-followup

Conversation

@clydin

@clydin clydin commented Oct 21, 2026

Copy link
Copy Markdown
Member

Chokidar 6 makes FSWatcher.close() terminal, throwing synchronously if watcher.add() is called once closing has started. Guard add(), remove(), scheduleBaselineCheck(), and checkChokidarBaselines() against watcher.closed, and clear tracked file state when the watcher is closed.

Additionally, replace the deprecated usePolling and interval Chokidar options with backend and pollingInterval. Remove the Chokidar 5 unlink re-watch workaround and its corresponding baseline check branch, as Chokidar 6 natively awaits recreated paths from their nearest existing ancestor across all watched directories.

@clydin clydin added the target: minor This PR is targeted for the next minor release label Oct 21, 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 simplifies the Chokidar file watcher implementation by removing complex baseline and unlink logic, and adds safety checks to prevent errors when adding or removing paths after the watcher is closed. The review feedback correctly points out that 'auto' is not a supported value for Chokidar's backend option and suggests using undefined instead to let Chokidar automatically select the appropriate backend.

Comment thread packages/angular/build/src/utils/watcher.ts
… v5 unlink workaround

Chokidar 6 makes `FSWatcher.close()` terminal, throwing synchronously if `watcher.add()` is called once closing has started. Guard `add()`, `remove()`, `scheduleBaselineCheck()`, and `checkChokidarBaselines()` against `watcher.closed`, and clear tracked file state when the watcher is closed.

Additionally, replace the deprecated `usePolling` and `interval` Chokidar options with `backend` and `pollingInterval`. Remove the Chokidar 5 `unlink` re-watch workaround and its corresponding baseline check branch, as Chokidar 6 natively awaits recreated paths from their nearest existing ancestor across all watched directories.
@alan-agius4
alan-agius4 force-pushed the refactor/chokidar-v6-followup branch from 1b2ac1d to a929bea Compare October 22, 2026 08:47
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Oct 22, 2026
@clydin
clydin merged commit 6284453 into angular:main Oct 22, 2026
40 checks passed
@clydin

clydin commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

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

@clydin
clydin deleted the refactor/chokidar-v6-followup branch October 22, 2026 15:17
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: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants