Skip to content

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

Closed
kevinWangSheng wants to merge 2 commits into
anomalyco:devfrom
kevinWangSheng:fix/run-exit-code-v2
Closed

kevinWangSheng wants to merge 2 commits into
anomalyco: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

@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.

@rekram1-node

Copy link
Copy Markdown
Member

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

5 participants