fix(init): use isatty(0) for TTY detection and add diagnostic probe#767
fix(init): use isatty(0) for TTY detection and add diagnostic probe#767
Conversation
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛Init
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
c0c3009 to
53407f7
Compare
|
53407f7 to
0a33220
Compare
Codecov Results 📊✅ 134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1649 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.50% 95.50% —%
==========================================
Files 253 254 +1
Lines 36666 36676 +10
Branches 0 0 —
==========================================
+ Hits 35019 35027 +8
- Misses 1647 1649 +2
- Partials 0 0 —Generated by Codecov Action |
Bun's single-file binaries don't deliver keypresses through TTY fds inherited via shell redirection (e.g. `curl | bash` → `exec sentry init </dev/tty` in install.sh) even though isatty(0) and setRawMode report success. A freshly opened /dev/tty fd from inside the process works, so open one in preamble() and forward its data events onto process.stdin. Route setRawMode to the fresh fd, and no-op pause/resume/_read on process.stdin to keep the stream machinery from hitting kqueue EINVAL on the broken fd between prompts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0a33220 to
a435af8
Compare
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.
Reviewed by Cursor Bugbot for commit a435af8. Configure here.

Summary
isatty(0)fromnode:ttyinstead ofprocess.stdin.isTTY(unreliable in Bun on inherited fds)process.stdin.isTTYwhenisatty(0)reports true but the property is undefined, preventing@clack/corefrom silently skippingsetRawModeSENTRY_INIT_DIAGNOSTICS=1) for future TTY-related bug reportsContext
A user reported that
curl -fsSL https://cli.sentry.dev/install | SENTRY_INIT=1 bashinstalls the binary but the first@clack/promptsconfirm prompt doesn't register keystrokes. The install script correctly runsexec "$sentry_bin" init </dev/ttyto reattach stdin to the terminal.Investigation result: We could not reproduce the bug with the current HEAD binary. Both the piped reproducer (
bash -c 'exec ./sentry init </dev/tty' < /dev/null) and the plain interactive run showed healthy TTY signals and accepted keystrokes normally.However, the init wizard was the last remaining site in the codebase still using
process.stdin.isTTYfor TTY detection. Six other sites (src/cli.ts,mutate-command.ts,commands/log/view.ts,commands/auth/login.ts,seer-trial.ts,commands/trial/start.ts) already useisatty(0)precisely becauseprocess.stdin.isTTYis known to be unreliable in Bun's single-file binary. This change closes that consistency gap.Diagnostic probe
The new
SENTRY_INIT_DIAGNOSTICS=1env var dumps a snapshot of stdin/stdout TTY state to stderr at two points: wizard entry and before the first prompt. If the bug resurfaces, reporters can include this output for targeted diagnosis instead of us guessing. Zero overhead when disabled.