fix(dsn): prevent silent exit during uncached DSN auto-detection (#411)#414
Merged
fix(dsn): prevent silent exit during uncached DSN auto-detection (#411)#414
Conversation
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Init
Issue List
Other
Bug Fixes 🐛Init
Other
Documentation 📚
Internal Changes 🔧Init
Other
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 104 passed | Total: 104 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 95.00%. Project has 697 uncovered lines. Files with missing lines (3)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 96.68% 96.68% —%
==========================================
Files 159 159 —
Lines 21011 21010 -1
Branches 0 0 —
==========================================
+ Hits 20314 20313 -1
- Misses 697 697 —
- Partials 0 0 —Generated by Codecov Action |
21676b8 to
55f9cf9
Compare
55f9cf9 to
19872f7
Compare
19872f7 to
824b07b
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
824b07b to
925c89e
Compare
925c89e to
a9a976f
Compare
Replace Bun.Glob.scan() async iterators with readdir() in DSN detection
paths. The async iterators don't ref-count the event loop, causing the
process to exit with code 0 and no output while scanning is still in
progress on first run (uncached).
Changes:
- bin.ts: Add setInterval keepalive cleared via .finally() to prevent
premature event loop drain (can't use top-level await due to CJS bundle)
- project-root.ts: Replace anyGlobMatches() Bun.Glob.scan() with
readdir() + synchronous Bun.Glob.match() for language marker detection
- env-file.ts: Replace Bun.Glob.scan('*') with readdir() in
detectFromMonorepoEnvFiles() for listing monorepo package directories
a9a976f to
1676436
Compare
pLimit.clearQueue() removes queued items from the internal queue, but the promises returned by limit() for those cleared items never settle. When used with Promise.all(), this causes the entire call to hang indefinitely. The earlyExit flag already causes queued tasks to return immediately when they reach the front of the queue, making clearQueue() both redundant and harmful. Bug: scanCodeForFirstDsn (stopOnFirst=true) would hang on any project with enough source files to exceed the concurrency limit of 50. Commands that relied on DSN auto-detection (e.g., 'sentry trial list' without explicit org) would silently exit with code 0 and no output.
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.

Problem
Commands using
resolveOrg()without an explicit org argument exit silently (code 0, no output) when the DSN cache is empty. Two root causes:main()call inbin.ts— nothing keeps the event loop alive while the returned Promise is pendingBun.Glob.scan()async iterators don't ref-count the event loop — used in two DSN detection paths, they let the event loop drain while scanning is still in progressFix
src/bin.ts: AddsetIntervalkeepalive cleared via.finally()to prevent premature event loop drain. Top-levelawaitisn't an option because the npm bundle uses esbuild CJS format.src/lib/dsn/project-root.ts: ReplaceBun.Glob.scan()inanyGlobMatches()withreaddir()+ synchronousBun.Glob.match()for language marker detection.src/lib/dsn/env-file.ts: ReplaceBun.Glob.scan("*")withreaddir()indetectFromMonorepoEnvFiles()for listing monorepo package directories.Both
readdir()andBun.Glob.match()properly ref-count the event loop / are synchronous, so they don't trigger the premature exit.Closes #411