fix(@angular/build): ensure chokidar watcher is ready before returning #34122

Merged
alan-agius4 opened 5:52pm on September 18, 2026 wanted to merge 1 commit into angular/angular-cli main from
fix-build-watcher-chokidar-ready

Pull Request Overview

  • Opened on September 18, 2026
  • Status Merged
  • Commit count 1 with first commit September 18, 2026

Total Delta

0 Total Diff Delta

Open Days

Open 1 weekdays

Test Delta

0 Diff Delta in Test Files
Breakdown by Phase

How long has this pull request spent in each phase of its lifecycle?

Fraction of total time Business days Phase
 
0.0 days Authoring 0 commits before pull request opened for review
 
0.0 days Awaiting first review
 
0.0 days Merge to deploy (still awaiting deployment)

Total time for pull request 0.0 business days from first commit authored to merge
Still awaiting deployment

Author avatar

fix(@angular/build): ensure chokidar watcher is ready before returning

When initializing chokidar.watch with ignoreInitial: true, files visited during the initial scan are treated as the initial baseline and do not emit change events. If createChokidarWatcher returns before the initial scan completes, subsequent file modifications made shortly after setup can be visited for the first time during the initial scan, causing the change event to be dropped.

Awaiting the ready event ensures the watcher's initial scan is completed and the watcher is actively listening before returning. This resolves test flakiness in rebuild error detection tests where files are modified immediately after the initial build.

Comments Threads Pending Resolution

clydin reviewed and approved this work on September 18, 2026
gemini-code-assist[bot] reviewed on September 18, 2026
gemini-code-assist[bot] left a comment

## Code Review

This pull request removes explicit timeouts from the dev-server build-errors test and updates the esbuild watcher initialization to await the 'ready' or 'error' events before returning. Feedback on the changes highlights a potential event listener leak in the watcher's promise implementation, suggesting that both 'ready' and 'error' listeners should be cleaned up once the promise settles.

Resolved Comment Threads

No resolved comments have been left on this PR.