Skip to content

fix(opencode): guard Bun.stdin.text() to prevent subprocess hang in non-interactive run - #1

Draft
MichaelHilton with Copilot wants to merge 1 commit into
mainfrom
copilot/fix-unit-linux-job-failure
Draft

fix(opencode): guard Bun.stdin.text() to prevent subprocess hang in non-interactive run#1
MichaelHilton with Copilot wants to merge 1 commit into
mainfrom
copilot/fix-unit-linux-job-failure

Conversation

CopilotAI commented Aug 13, 2026

Copy link
Copy Markdown

All 10 tests in test/cli/run/run-process.test.ts timed out because the CLI subprocess hung indefinitely before producing any output. The subprocess stderr contained only Error: Timed out, with empty stdout and exit code -1 (killed by the test harness after 30 s).

Root cause

src/cli/cmd/run.ts line 416:

constpiped=process.stdin.isTTY ? undefined : awaitBun.stdin.text()

The test harness spawns the CLI via ChildProcess.make(..., { stdin: "ignore" })cross-spawn → Bun's Node.js child_process.spawn compat layer. With stdin: "ignore", process.stdin.isTTY is undefined (falsy), so Bun.stdin.text() is always called. Bun's compat layer does not reliably redirect stdin to /dev/null for the "ignore" stdio option, leaving stdin as an open pipe — causing Bun.stdin.text() to block forever.

Fix

Guard the Bun.stdin.text() call with an additional check so it is only invoked when stdin is actually readable:

constpiped=process.stdin.isTTY||!process.stdin.readable
? undefined
: awaitBun.stdin.text()

When stdin is set to "ignore", process.stdin.readable is false, so the blocking read is skipped and the subprocess proceeds normally.

How did you verify your code works?

Ran bun test test/cli/run/run-process.test.ts in packages/opencode — all 10 previously failing tests pass.

Screenshots / recordings

N/A — no UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

CopilotAI changed the title [WIP] Fix failing GitHub Actions job 'unit (linux)'fix(opencode): guard Bun.stdin.text() to prevent subprocess hang in non-interactive runAug 13, 2026
Sign up for freeto 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

@MichaelHilton