fix(server): bound OpenCode CLI health probes with timeouts #6577
main fromrefs/pull/6577/head·opened View on GitHubWhat Changed#
The OpenCode provider health probes (opencode --version and the model inventory commands via loadInventoryFromCli) awaited child.exitCode with no timeout, so a hung opencode binary (waiting on stdin, stuck on a lock, wedged build) stalled the provider snapshot indefinitely and leaked the spawned process. Every other provider adapter already bounds its probes — Codex (CodexProvider.ts), Claude, Cursor, and Grok all wrap probe commands in Effect.timeoutOption; OpenCode was the only one without.
This wraps both OpenCode probe call sites in Effect.timeoutOption:
- 4s for the version probe (matches
GrokProvider's version probe budget) - 15s for the model inventory probe (matches the Grok/Cursor model-discovery budgets; the CLI path can run two subcommands with one 1s-spaced retry)
On timeout the snapshot now reports a clear error (Failed to execute OpenCode CLI health check: Timed out while ..., or the friendly "couldn't reach the configured server" message for external-server setups) instead of hanging. The spawned child is acquired under Effect.scoped in runOpenCodeCommand, so the timeout interrupts the effect and the scope finalizer kills the process — no zombie.
Adds two focused tests (hung version probe, hung inventory probe) using TestClock.
Why#
A hung OpenCode CLI leaves the provider stuck in a pending/probing state forever, which previously also surfaced as a cold-start blocker (#2248 — fixed once before, then reintroduced when the health check moved to CLI probes). Bounding the probes turns a silent permanent hang into a bounded, diagnosable failure.
Verified: vp test run on the OpenCode provider/adapter/text-generation test files (48 tests, all passing), targeted typecheck and lint clean.
Checklist#
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes (N/A — server-only, no UI changes)
- I included a video for animation/interaction changes (N/A)
Note
Low Risk Server-only OpenCode health probing; bounded timeouts replace an indefinite hang and match patterns already used by other CLI providers.
Overview
OpenCode’s CLI health check could hang forever when opencode --version or model inventory probes never finish, leaving the provider snapshot stuck probing. This change caps those probes with Effect.timeoutOption: 4s for version (same as Grok) and 15s for inventory.
When a probe exceeds its budget, checkOpenCodeProviderStatus returns an error snapshot with explicit timeout messages instead of blocking indefinitely. Tests extend the runtime mock with hang flags and use TestClock + forked fibers to assert both timeout paths.
Note
Bound OpenCode CLI health probes in checkOpenCodeProviderStatus with 4s and 15s timeouts#
- Wraps the
--versionprobe inEffect.timeoutOption(VERSION_PROBE_TIMEOUT_MS)(4000 ms) and the inventory load inEffect.timeoutOption(INVENTORY_PROBE_TIMEOUT_MS)(15000 ms) in OpenCodeProvider.ts. - On timeout, returns a fallback snapshot with a specific error message (
Timed out while running opencode --versionorTimed out while loading the OpenCode model inventory) instead of waiting indefinitely. - Adds tests in OpenCodeProvider.test.ts that fork the health check and advance
TestClockby 30s to assert the timeout error messages for both probes. - Behavioral Change: version and inventory probes that previously hung forever now fail after their respective timeouts;
Exitvalues now wrapOptionto account fortimeoutOptionresults.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved at
e6fcc78Macroscope's review found this PR approvable — This small server-side fix replaces indefinite OpenCode health-check hangs with bounded, diagnosable failures while leaving successful probe behavior unchanged. Focused tests cover both timeout scenarios, and no sensitive or deployment-related files are affected.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
dede434f-b6a0-4069-b498-fb507e04916dYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Comment `@coderabbitai help` to get the list of available commands.