Skip to content

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

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:refactor/chokidar-v6-followup
Open

clydin wants to merge 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.

… 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.
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant