fix: preserve TTY in dev mode by inlining tsx invocation#1026
Merged
Conversation
Member
|
The verification steps show The working form is without
|
The `cli` and `dev` scripts used `pnpm tsx src/bin.ts`, which is shorthand for `pnpm run tsx` — a nested pnpm lifecycle spawn. The inner spawn loses TTY inheritance, so `process.stdin.isTTY` is undefined and interactive commands like `sentry init` fall back to non-interactive mode. Replace `pnpm tsx` with the inlined `tsx --import ./script/require-shim.mjs` in `cli` and `dev` only. This keeps a single pnpm lifecycle layer that uses `stdio: 'inherit'`, preserving the terminal's TTY. The `tsx` script alias remains for the 19+ non-interactive scripts (build, generate, check, bench).
d06ca98 to
31d6e7b
Compare
Member
Author
|
Good catch! Updated the PR description to use |
Contributor
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 4296 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 82.04% 82.04% —%
==========================================
Files 329 329 —
Lines 23917 23917 —
Branches 15634 15634 —
==========================================
+ Hits 19620 19621 +1
- Misses 4297 4296 -1
- Partials 1652 1652 —Generated by Codecov Action |
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
pnpm run cli initandpnpm run dev initcannot runsentry initinteractively because TTY is lost during execution.Root cause: The
cliscript was"pnpm tsx src/bin.ts".pnpm tsxis shorthand forpnpm run tsx, which creates a nested pnpm lifecycle spawn (outer pnpm → shell → inner pnpm → shell → tsx). The inner spawn loses TTY inheritance, soprocess.stdin.isTTYandprocess.stdout.isTTYareundefinedin the final Node process.This triggers three gates that block interactive mode:
isNonInteractiveContext()ininit.ts→ requires--yes+--featuresisInteractiveTerminal()infactory.ts→ forces LoggingUI instead of InkUIwizard-runner.ts→ throws WizardErrorFix
Inline
tsx --import ./script/require-shim.mjsdirectly into theclianddevscripts, eliminating the nestedpnpm run tsxlifecycle spawn.With a single pnpm lifecycle layer, pnpm uses
stdio: 'inherit', preserving the terminal's TTY fds.The
tsxscript alias remains for the 19+ non-interactive scripts (build, generate, check, bench) where TTY doesn't matter.Verification
In a real terminal:
Both should now enter interactive mode (InkUI) instead of erroring about non-interactive context.