Skip to content

fix(dsn): limit concurrent stat() calls in project root detection (CLI-19A)#768

Merged
BYK merged 3 commits intomainfrom
fix/cli-19a-kqueue-concurrency
Apr 17, 2026
Merged

fix(dsn): limit concurrent stat() calls in project root detection (CLI-19A)#768
BYK merged 3 commits intomainfrom
fix/cli-19a-kqueue-concurrency

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Apr 17, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Bug Fixes 🐛

Init

  • Use isatty(0) for TTY detection and add diagnostic probe by BYK in #767
  • Reuse detected existing project data by betegon in #766
  • Ensure project reuse and spinner states by MathurAditya724 in #763

Other

  • (dsn) Limit concurrent stat() calls in project root detection (CLI-19A) by BYK in #768

Internal Changes 🔧

  • Regenerate docs by github-actions[bot] in e02799c1

🤖 This preview updates automatically when you update the PR.

@BYK BYK marked this pull request as ready for review April 17, 2026 20:53
…I-19A)

processDirectoryLevel fires up to 68 parallel stat() calls per directory
level through anyExists() (VCS: 7, CI: 12, language: 30, build: 19), all
sharing no concurrency limit. On macOS, this exhausts kqueue file descriptor
limits for deeply nested projects, surfacing as EINVAL.

Add a module-scoped pLimit(32) instance (statLimit) shared across every
anyExists() call so total concurrent stat() calls are capped at 32 regardless
of how many marker groups run in parallel. The shared limiter bounds total FD
pressure — not per-group pressure — matching the pattern in response-cache.ts.

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.
Leaves comfortable headroom under macOS's ~256 kqueue FD ceiling.
@BYK BYK force-pushed the fix/cli-19a-kqueue-concurrency branch from 3b04a59 to c408dc2 Compare April 17, 2026 21:11
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-768/

Built to branch gh-pages at 2026-04-17 21:27 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

Codecov Results 📊

138 passed | Total: 138 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +4
Passed Tests 📈 +4
Failed Tests
Skipped Tests

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 1652 uncovered lines.
❌ Project coverage is 95.5%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    95.51%    95.50%    -0.01%
==========================================
  Files          254       254         —
  Lines        36676     36678        +2
  Branches         0         0         —
==========================================
+ Hits         35027     35026        -1
- Misses        1649      1652        +3
- Partials         0         0         —

Generated by Codecov Action

Comment thread test/lib/dsn/project-root.test.ts Outdated
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c408dc2. Configure here.

Comment thread test/lib/dsn/project-root.test.ts Outdated
Comment thread test/lib/dsn/project-root.test.ts Outdated
@BYK BYK merged commit a2267ab into main Apr 17, 2026
27 checks passed
@BYK BYK deleted the fix/cli-19a-kqueue-concurrency branch April 17, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant