Skip to content

fix(opencode): wait for shell output before returning#30003

Open
dstaple wants to merge 1 commit into
anomalyco:devfrom
dstaple:dstaple/fix-shell-race-condition
Open

fix(opencode): wait for shell output before returning#30003
dstaple wants to merge 1 commit into
anomalyco:devfrom
dstaple:dstaple/fix-shell-race-condition

Conversation

@dstaple
Copy link
Copy Markdown

@dstaple dstaple commented May 30, 2026

Issue for this PR

Closes #30001

Type of change

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

What does this PR do?

Fixes a race in ShellTool where the process exit can complete before the stdout/stderr stream has fully drained.

The shell output reader already runs in a forked fiber, but the final result was built without waiting for that fiber. This PR joins the output-reader fiber before computing the final shell output, so emitted output is not reported as (no output) or truncated.

I also added a test which repros the issue (fails) on dev but passes on this branch.

How did you verify your code works?

  • bun test
  • bun typecheck
  • Wrote a test that fails on dev but passes on this branch
  • bun dev
  • ran shell commands through the live bun dev instance and confirmed output was returned

Screenshots / recordings

N/A

Checklist

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

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.

ShellTool can return before the output stream drains

1 participant