Skip to content

fix(dsn): prevent silent exit during uncached DSN auto-detection (#411)#414

Merged
BYK merged 2 commits intomainfrom
fix/411-silent-exit-dsn-detection
Mar 13, 2026
Merged

fix(dsn): prevent silent exit during uncached DSN auto-detection (#411)#414
BYK merged 2 commits intomainfrom
fix/411-silent-exit-dsn-detection

Conversation

@BYK
Copy link
Member

@BYK BYK commented Mar 12, 2026

Problem

Commands using resolveOrg() without an explicit org argument exit silently (code 0, no output) when the DSN cache is empty. Two root causes:

  1. Bare main() call in bin.ts — nothing keeps the event loop alive while the returned Promise is pending
  2. Bun.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 progress

Fix

  • src/bin.ts: Add setInterval keepalive cleared via .finally() to prevent premature event loop drain. Top-level await isn't an option because the npm bundle uses esbuild CJS format.
  • src/lib/dsn/project-root.ts: Replace Bun.Glob.scan() in anyGlobMatches() with readdir() + synchronous Bun.Glob.match() for language marker detection.
  • src/lib/dsn/env-file.ts: Replace Bun.Glob.scan("*") with readdir() in detectFromMonorepoEnvFiles() for listing monorepo package directories.

Both readdir() and Bun.Glob.match() properly ref-count the event loop / are synchronous, so they don't trigger the premature exit.

Closes #411

@github-actions
Copy link
Contributor

github-actions bot commented Mar 12, 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).


New Features ✨

Init

  • Add --team flag to relay team selection to project creation by MathurAditya724 in #403
  • Enforce canonical feature display order by betegon in #388
  • Accept multiple delimiter formats for --features flag by betegon in #386
  • Add git safety checks before wizard modifies files by betegon in #379
  • Add experimental warning before wizard runs by betegon in #378
  • Add init command for guided Sentry project setup by betegon in #283

Issue List

  • Auto-compact when table exceeds terminal height by BYK in #395
  • Redesign table to match Sentry web UI by BYK in #372

Other

  • (trial) Auto-prompt for Seer trial + sentry trial list/start commands by BYK in #399
  • Support SENTRY_HOST as alias for SENTRY_URL by betegon in #409
  • Add --dry-run flag to mutating commands by BYK in #387
  • Return-based output with OutputConfig on buildCommand by BYK in #380
  • Add --fields flag for context-window-friendly JSON output by BYK in #373
  • Magic @ selectors (@latest, @most_frequent) for issue commands by BYK in #371
  • Input hardening against agent hallucinations by BYK in #370
  • Add response caching for read-only API calls by BYK in #330

Bug Fixes 🐛

Init

  • Remove implementation detail from help text by betegon in #385
  • Truncate uncommitted file list to first 5 entries by MathurAditya724 in #381

Other

  • (api) Convert --data to query params for GET requests by BYK in #383
  • (docs) Remove double borders and fix column alignment on landing page tables by betegon in #369
  • Show human-friendly names in trial list and surface plan trials by BYK in #412
  • Add trace ID validation to trace view + UUID dash-stripping by BYK in #375

Documentation 📚

  • Update credential storage docs and remove stale config.json references by betegon in #408

Internal Changes 🔧

Init

  • Remove --force flag by betegon in #377
  • Remove dead determine-pm step label by betegon in #374

Other

  • (log/list) Convert non-follow paths to return CommandOutput by BYK in #410
  • Convert list command handlers to return data instead of writing stdout by BYK in #404
  • Split api-client.ts into focused domain modules by BYK in #405
  • Migrate non-streaming commands to CommandOutput with markdown rendering by BYK in #398
  • Convert Tier 2-3 commands to return-based output and consola by BYK in #394
  • Convert remaining Tier 1 commands to return-based output by BYK in #382
  • Converge Tier 1 commands to writeOutput helper by BYK in #376

Other

  • Minify JSON on read and pretty-print on write in init local ops by MathurAditya724 in #396

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 12, 2026

Codecov Results 📊

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

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 95.00%. Project has 697 uncovered lines.
✅ Project coverage is 96.68%. Comparing base (base) to head (head).

Files with missing lines (3)
File Patch % Lines
code-scanner.ts 97.83% ⚠️ 7 Missing
project-root.ts 98.08% ⚠️ 6 Missing
env-file.ts 98.32% ⚠️ 2 Missing
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

@BYK BYK force-pushed the fix/411-silent-exit-dsn-detection branch 2 times, most recently from 21676b8 to 55f9cf9 Compare March 12, 2026 21:16
@BYK BYK marked this pull request as ready for review March 13, 2026 10:04
@BYK BYK force-pushed the fix/411-silent-exit-dsn-detection branch from 55f9cf9 to 19872f7 Compare March 13, 2026 10:08
@BYK BYK force-pushed the fix/411-silent-exit-dsn-detection branch from 19872f7 to 824b07b Compare March 13, 2026 11:42
Copy link

@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.

@BYK BYK force-pushed the fix/411-silent-exit-dsn-detection branch from 824b07b to 925c89e Compare March 13, 2026 11:52
@BYK BYK force-pushed the fix/411-silent-exit-dsn-detection branch from 925c89e to a9a976f Compare March 13, 2026 11:57
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
@BYK BYK force-pushed the fix/411-silent-exit-dsn-detection branch from a9a976f to 1676436 Compare March 13, 2026 12:51
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.
@BYK BYK merged commit 0aa2a22 into main Mar 13, 2026
22 checks passed
@BYK BYK deleted the fix/411-silent-exit-dsn-detection branch March 13, 2026 13:59
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.

Bug: Process exits silently with no output when DSN auto-detection is slow (uncached first run)

1 participant