Skip to content

fix(cli): set non-zero exit code when run command encounters errors#14625

Open
kevinWangSheng wants to merge 2 commits intoanomalyco:devfrom
kevinWangSheng:fix/run-exit-code-v2
Open

fix(cli): set non-zero exit code when run command encounters errors#14625
kevinWangSheng wants to merge 2 commits intoanomalyco:devfrom
kevinWangSheng:fix/run-exit-code-v2

Conversation

@kevinWangSheng
Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #14551

Type of change

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

What does this PR do?

opencode run exits with code 0 even when the session encounters errors, breaking CI/CD pipelines. The fix awaits the event loop completion and sets process.exitCode = 1 when errors occurred.

How did you verify your code works?

Verified the exit code changes to 1 when the session produces errors. Only run.ts is modified.

Screenshots / recordings

N/A - no UI change.

Checklist

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

shenghui kevin and others added 2 commits February 21, 2026 18:09
@sivanzcw
Copy link
Copy Markdown

I’m also seeing this issue. When opencode terminates unexpectedly, the exit code is not reported correctly. This PR would be very helpful — hope it can be merged soon.

@diandian1997
Copy link
Copy Markdown

Same issue. Running opencode run with benchmark with all exit codes 0, please consider fixing this bug.

@cokekitten
Copy link
Copy Markdown

Heads-up — I opened #26588 with a smaller alternative for the same bug (sets process.exitCode = 1 directly inside the session.error handler in loop(), +1 line). Apologies for the dup; I didn't notice this PR until github-actions surfaced it after I'd already pushed. Happy to close mine if you'd rather have yours go through — you've been waiting a while.

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.

fix: run command exits with 0 on session errors

4 participants