Skip to content

fix(opencode): wait for shell output drain#29230

Closed
YOMXXX wants to merge 1 commit into
anomalyco:devfrom
YOMXXX:fix/shell-terminal-fallback-flake
Closed

fix(opencode): wait for shell output drain#29230
YOMXXX wants to merge 1 commit into
anomalyco:devfrom
YOMXXX:fix/shell-terminal-fallback-flake

Conversation

@YOMXXX
Copy link
Copy Markdown

@YOMXXX YOMXXX commented May 25, 2026

Issue for this PR

Closes #29214

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

ShellTool.run was returning as soon as the child process exit code resolved. The output reader runs in a scoped fiber, so the scope could close before buffered stdout/stderr chunks were processed. That made short shell commands occasionally return (no output) even though the process printed text.

This PR keeps the output reader fiber and waits for it to drain before building the final shell result. It also adds a deterministic regression test where the process exit resolves before the output stream emits.

How did you verify your code works?

  • bun test test/tool/shell.test.ts from packages/opencode
  • 20 repeated runs of bun test test/tool/shell.test.ts -t "falls back from terminal-only configured shell" from packages/opencode
  • bun typecheck from packages/opencode
  • bun turbo typecheck from the repo root
  • .husky/pre-push

Screenshots / recordings

No UI changes.

Checklist

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

@thdxr thdxr closed this May 27, 2026
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.

Flaky test in test/tool/shell.test.ts (falls back from terminal-only)

2 participants