Skip to content

Commit a2267ab

Browse files
authored
fix(dsn): limit concurrent stat() calls in project root detection (CLI-19A) (#768)
## Summary - `processDirectoryLevel` fires up to 68 parallel `stat()` calls per directory level through `anyExists()` (VCS: 7, CI: 12, language: 30, build: 19) with no concurrency limit - On macOS, this exhausts kqueue file descriptor limits for deeply nested projects, surfacing as `EINVAL` (CLI-19A) - Add a module-scoped `pLimit(32)` instance (`statLimit`) shared across every `anyExists()` call ## Approach The shared limiter bounds **total** FD pressure across all marker groups, not per-group pressure — so 4 parallel `anyExists()` groups still share a single 32-slot budget. Matches the pattern in `response-cache.ts` (`const cacheIO = pLimit(CACHE_IO_CONCURRENCY)`). 32 keeps VCS (7) and CI (12) marker checks fully parallel while throttling only the larger `LANGUAGE_MARKERS` (30) and `BUILD_SYSTEM_MARKERS` (19) groups, staying well under macOS's ~256 kqueue FD ceiling. ## Changes - `src/lib/dsn/project-root.ts` — add `STAT_CONCURRENCY = 32` exported constant + shared `statLimit`, wrap `pathExists` in `anyExists()` with it - `test/lib/dsn/project-root.test.ts` — add concurrency cap test (mocks `stat` to track peak concurrent calls, asserts ≤ `STAT_CONCURRENCY`) and early-exit preservation test
1 parent 9b70860 commit a2267ab

3 files changed

Lines changed: 171 additions & 59 deletions

File tree

0 commit comments

Comments
 (0)