Skip to content

Commit c1c4216

Browse files
clydindgp1130
authored andcommitted
fix(@angular/build): coalesce external watcher directories to avoid macOS FSEvents limit
Previously, `ParcelExternalManager` immediately created a separate `@parcel/watcher` subscription for the parent directory of every watched file outside the workspace root. In monorepo setups where an application imports from hundreds of external library directories and hoisted `node_modules` packages, this exceeded macOS's ~512 per-process `FSEvents` stream limit, causing subsequent subscriptions to silently fail and miss file changes. To prevent exhausting native watcher streams, `ParcelExternalManager` now normalizes external `node_modules` file paths to their package root directory and batches synchronous file additions and removals within a microtask so nested child directories are subsumed before subscribing. When the number of external target directories exceeds the subscription budget of 256, a prefix tree is used to iteratively collapse the deepest branching subdirectories into common ancestors while preferring directories that do not contain `workspaceRoot`. Additionally, if `parcelWatcher.subscribe()` rejects for an existing directory on disk, the manager dynamically lowers its subscription budget and re-reconciles into higher-level ancestor directories. Closes #34246 (cherry picked from commit d2233e2)
1 parent 116cb93 commit c1c4216

3 files changed

Lines changed: 866 additions & 78 deletions

File tree

‎packages/angular/build/BUILD.bazel‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ ts_project(
146146
":build",
147147
":node_modules/@angular-devkit/core",
148148
":node_modules/@babel/core",
149+
":node_modules/@parcel/watcher",
149150
":node_modules/oxc-parser",
150151
"//:node_modules/@angular/compiler-cli",
151152
"//:node_modules/@angular/router",

0 commit comments

Comments
 (0)