opencode run hangs forever on API errors (breaks CLI/automation integrations) #5286

Open
opened 2026-02-16 17:50:55 -05:00 by yindo · 0 comments
Owner

Originally created by @EivMeyer on GitHub (Jan 13, 2026).

Originally assigned to: @rekram1-node on GitHub.

Bug Description

When opencode run encounters an API error (e.g., 429 rate limit), it logs the error but never exits - it hangs indefinitely. This breaks any CLI tool or automation system that spawns opencode as a subprocess.

Reproduction

# With an expired/rate-limited account:
timeout 30 opencode run "what is 1+1"
# Result: hangs for 30 seconds, exit code 124 (timeout)

Expected Behavior

opencode should fail fast with a non-zero exit code and clear error message:

Error: API rate limited (429). Please check your subscription status.
Exit code: 1

Actual Behavior

opencode logs the error internally but continues running forever:

ERROR service=llm error={"statusCode":429,...} 
# Then hangs indefinitely - no exit, no output to user

Impact

This breaks integrations like zeroshot which spawn CLI tools as subprocesses:

// zeroshot spawns opencode
exec('opencode run "task"', (error, stdout) => {
  // This callback NEVER fires because opencode never exits
});

Workaround: We've added timeouts to our subprocess calls, but the real fix should be in opencode.

Environment

  • opencode version: 1.1.16
  • OS: Linux (Ubuntu 22.04)
  • Auth: OpenAI OAuth

Suggested Fix

In the error handling path, ensure the process exits with non-zero code:

if (response.status === 429) {
  console.error('Error: API rate limited. Check subscription status.');
  process.exit(1);  // <-- Currently missing
}

Or more generally: any unrecoverable API error should cause opencode run to exit, not hang.

Originally created by @EivMeyer on GitHub (Jan 13, 2026). Originally assigned to: @rekram1-node on GitHub. ## Bug Description When `opencode run` encounters an API error (e.g., 429 rate limit), it logs the error but **never exits** - it hangs indefinitely. This breaks any CLI tool or automation system that spawns opencode as a subprocess. ## Reproduction ```bash # With an expired/rate-limited account: timeout 30 opencode run "what is 1+1" # Result: hangs for 30 seconds, exit code 124 (timeout) ``` ## Expected Behavior opencode should **fail fast** with a non-zero exit code and clear error message: ``` Error: API rate limited (429). Please check your subscription status. Exit code: 1 ``` ## Actual Behavior opencode logs the error internally but continues running forever: ``` ERROR service=llm error={"statusCode":429,...} # Then hangs indefinitely - no exit, no output to user ``` ## Impact This breaks integrations like [zeroshot](https://github.com/covibes/zeroshot) which spawn CLI tools as subprocesses: ```javascript // zeroshot spawns opencode exec('opencode run "task"', (error, stdout) => { // This callback NEVER fires because opencode never exits }); ``` **Workaround**: We've added timeouts to our subprocess calls, but the real fix should be in opencode. ## Environment - opencode version: 1.1.16 - OS: Linux (Ubuntu 22.04) - Auth: OpenAI OAuth ## Suggested Fix In the error handling path, ensure the process exits with non-zero code: ```typescript if (response.status === 429) { console.error('Error: API rate limited. Check subscription status.'); process.exit(1); // <-- Currently missing } ``` Or more generally: any unrecoverable API error should cause `opencode run` to exit, not hang.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#5286