A team launch repeatedly changes the watched target set (new dirs appear), and each change tore down the chokidar watcher and recreated it over the full target set. On macOS chokidar uses kqueue with one fd per watched file, so every rebuild re-opened an fd for EVERY watched file (the large always-watched inbox set plus scoped dirs). Profiling a 6-member mixed launch showed ~54k open() syscalls dominated by these rebuilds. Keep one persistent watcher and apply target-set changes with add()/unwatch() on the delta only, so a reconcile opens fds for just the newly added dirs. The initial watcher still uses ignoreInitial for a silent startup baseline, and emitExistingFilesForNewTargets still backfills files already present in newly added dirs, so the emitted event surface is unchanged. Because the watcher is no longer recreated per reconcile, the stale-old-generation and close-throws-during-rebuild failure modes are gone; their tests are replaced with incremental add/unwatch and persistent-watcher coverage. All 69 watcher tests pass. |
||
|---|---|---|
| .. | ||
| agent-graph | ||
| features | ||
| fixtures | ||
| main | ||
| mocks | ||
| preload | ||
| renderer | ||
| scripts | ||
| shared | ||
| setup.ts | ||