fix(@angular/build): ensure chokidar watcher is ready before returning - #34122
Merged
alan-agius4 merged 2 commits intoSep 18, 2026
Merged
Conversation
There was a problem hiding this 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.
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.
alan-agius4
force-pushed
the
fix-build-watcher-chokidar-ready
branch
from
September 18, 2026 16:00
23d0e67 to
f22bff9
Compare
clydin
approved these changes
Sep 18, 2026
Collaborator
Author
1 task done
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.
When initializing
chokidar.watchwithignoreInitial: true, files visited during the initial scan are treated as the initial baseline and do not emit change events. IfcreateChokidarWatcherreturns 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
readyevent 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.