fix(dsn): prevent hang during DSN auto-detection in repos with test fixtures#445
Merged
fix(dsn): prevent hang during DSN auto-detection in repos with test fixtures#445
Conversation
…ixtures DSN auto-detection was hanging when run in repos containing many test fixture DSNs (e.g., the CLI repo itself). PR #420 bumped scan depth from 2→3, causing test/ directories to be scanned. This found ~86 fake DSNs that were all resolved via unbounded Promise.all — triggering 190+ concurrent API requests, rate limiting, and retry storms. Fixes: - Skip test/, tests/, __mocks__, fixtures/, __fixtures__ in scanner - Deduplicate DSNs by (orgId, projectId) before API resolution - Add p-limit(5) concurrency cap on DSN resolution API calls - Add 15s timeout with partial results for DSN resolution - Add in-flight promise dedup for resolveOrgRegion (concurrent calls for the same org share one HTTP request) - Fix getDirMtime to use static import instead of dynamic import
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 111 passed | Total: 111 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 93.85%. Project has 1076 uncovered lines. Files with missing lines (2)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.24% 95.24% —%
==========================================
Files 167 167 —
Lines 22542 22602 +60
Branches 0 0 —
==========================================
+ Hits 21469 21526 +57
- Misses 1073 1076 +3
- Partials 0 0 —Generated by Codecov Action |
BYK
commented
Mar 17, 2026
- Rename regionPromises → regionCache (BYK suggestion) - Evict rejected promises from regionCache via .catch handler so retries after re-authentication work (Seer + BugBot) - Use limit.map helper instead of manual map + Promise.all (BYK) - Replace setTimeout + Promise.race with AbortSignal.timeout — self-cleaning, doesn't hold event loop (BYK + BugBot) - Queued tasks check signal.aborted before work (code-scanner earlyExit pattern from PR #414) - Take AGENTS.md from origin/main to resolve merge conflict
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
The AbortSignal.timeout only prevents queued tasks from starting but doesn't abort already in-flight HTTP requests. Race limit.map against the abort signal so the function returns on timeout even if some tasks are still running. Results are written to a shared array so partial results survive the race.
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.

Running
sentry issueswithout explicit flags in repos containing test fixture DSNs (e.g., the CLI repo itself) caused the process to hang. PR #420 bumped scan depth from 2→3, causingtest/directories to be scanned — finding ~86 fake DSNs that were all resolved via unboundedPromise.all, triggering 190+ concurrent API requests, rate limiting (429), and retry storms.Changes
test/,tests/,__mocks__/,fixtures/,__fixtures__/toALWAYS_SKIP_DIRS. Test directories contain fixture DSNs, not real Sentry configuration.(orgId, projectId)orpublicKey, resolving only one representative per unique pair. Reduces ~86 DSNs to ~10-20 unique API calls.p-limit(5)on DSN resolution API calls to prevent overwhelming the Sentry API.Promise.allagainst a deadline, returning partial results on timeout so the CLI never hangs indefinitely.resolveOrgRegion— Concurrent calls for the same orgSlug share a single HTTP request via a module-level promise cache.getDirMtimedynamic import — Replace wastefulawait import("node:fs/promises")(called 75+ times) with a static import.Relates to #420 and #414.