[PR #4223] fix(cli): ensure clean exit on provider/model errors #10907

Closed
opened 2026-02-16 18:15:40 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/4223

State: closed
Merged: Yes


Summary

  • Add actionable error formatting for ProviderModelNotFoundError and ProviderInitError.
  • Ensure the CLI exits cleanly by confirming teardown of process-scoped state (already present on dev).

Context

  • The hang was caused by process-scoped services (watchers, etc.) not being disposed when errors occurred during opencode run.
  • The teardown via try/finally in bootstrap is already on dev; this PR contributes the friendly error messages to guide users when provider/model resolution fails.

Reproduction

opencode run --model typo/claude-haiku-4-5 "hi there"

Observed (pre-fix): noisy stack + process required Ctrl+C.

Change

  • packages/opencode/src/cli/error.ts
    • Format provider/model errors into actionable guidance
  • packages/opencode/src/cli/bootstrap.ts
    • No diff vs dev (teardown exists upstream)

Notes

  • A prior change (#3083) sought to avoid hangs via explicit exit. The upstream dev now guarantees teardown via try/finally; this PR complements that by improving the UX for a common misconfiguration.

Testing

  • With upstream teardown + this change, the above repro exits with code 1 and shows actionable guidance.
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/4223 **State:** closed **Merged:** Yes --- Summary - Add actionable error formatting for ProviderModelNotFoundError and ProviderInitError. - Ensure the CLI exits cleanly by confirming teardown of process-scoped state (already present on `dev`). Context - The hang was caused by process-scoped services (watchers, etc.) not being disposed when errors occurred during `opencode run`. - The teardown via try/finally in bootstrap is already on `dev`; this PR contributes the friendly error messages to guide users when provider/model resolution fails. Reproduction ``` opencode run --model typo/claude-haiku-4-5 "hi there" ``` Observed (pre-fix): noisy stack + process required Ctrl+C. Change - packages/opencode/src/cli/error.ts - Format provider/model errors into actionable guidance - packages/opencode/src/cli/bootstrap.ts - No diff vs `dev` (teardown exists upstream) Notes - A prior change (#3083) sought to avoid hangs via explicit exit. The upstream `dev` now guarantees teardown via try/finally; this PR complements that by improving the UX for a common misconfiguration. Testing - With upstream teardown + this change, the above repro exits with code 1 and shows actionable guidance.
yindo added the pull-request label 2026-02-16 18:15:40 -05:00
yindo closed this issue 2026-02-16 18:15:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10907