Skip to content

fix: preserve TTY in dev mode by inlining tsx invocation#1026

Open
BYK wants to merge 1 commit into
mainfrom
fix/dev-tty-preservation
Open

fix: preserve TTY in dev mode by inlining tsx invocation#1026
BYK wants to merge 1 commit into
mainfrom
fix/dev-tty-preservation

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented May 27, 2026

Problem

pnpm run dev -- init and pnpm run cli -- init cannot run sentry init interactively because TTY is lost during execution.

Root cause: The cli script was "pnpm tsx src/bin.ts". pnpm tsx is shorthand for pnpm run tsx, which creates a nested pnpm lifecycle spawn (outer pnpm → shell → inner pnpm → shell → tsx). The inner spawn loses TTY inheritance, so process.stdin.isTTY and process.stdout.isTTY are undefined in the final Node process.

This triggers three gates that block interactive mode:

  1. isNonInteractiveContext() in init.ts → requires --yes + --features
  2. isInteractiveTerminal() in factory.ts → forces LoggingUI instead of InkUI
  3. Wizard preamble in wizard-runner.ts → throws WizardError

Fix

Inline tsx --import ./script/require-shim.mjs directly into the cli and dev scripts, eliminating the nested pnpm run tsx lifecycle spawn.

With a single pnpm lifecycle layer, pnpm uses stdio: 'inherit', preserving the terminal's TTY fds.

The tsx script alias remains for the 19+ non-interactive scripts (build, generate, check, bench) where TTY doesn't matter.

Verification

In a real terminal:

pnpm run cli -- init --dry-run
pnpm run dev -- init --dry-run

Both should now enter interactive mode (InkUI) instead of erroring about non-interactive context.

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).
@BYK BYK enabled auto-merge (squash) May 27, 2026 08:39
@betegon
Copy link
Copy Markdown
Member

betegon commented May 27, 2026

The verification steps show pnpm run cli -- init --dry-run but the -- actually gets passed through to process.argv, causing commander to fail with Command not found: -- init ....

The working form is without --:

pnpm run cli init --dry-run
pnpm run cli init /path/to/project

-- is only needed when passing flags that pnpm might intercept — but since pnpm passes it through verbatim here, it breaks subcommand parsing.

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.

2 participants