Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): bound OpenCode CLI health probes with timeouts #6577

ClosedAdolanium(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/6577/headopened View on GitHub

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

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit e6fcc788179b56645698fef465f1c4fb2f21bc87. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Bound OpenCode CLI health probes in checkOpenCodeProviderStatus with 4s and 15s timeouts

  • Wraps the --version probe in Effect.timeoutOption(VERSION_PROBE_TIMEOUT_MS) (4000 ms) and the inventory load in Effect.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 --version or Timed out while loading the OpenCode model inventory) instead of waiting indefinitely.
  • Adds tests in OpenCodeProvider.test.ts that fork the health check and advance TestClock by 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; Exit values now wrap Option to account for timeoutOption results.
Macroscope summarized e6fcc78.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: dede434f-b6a0-4069-b498-fb507e04916d

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at e6fcc78

      Macroscope'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).
    4. Note

      🤖 GPT-5.6 Sol responding on behalf of Theo

      Closing this because #8750 now gives the OpenCode version probe a four-second limit and cleans up its process group. #8480 moved model inventory to the managed server and SDK, so the CLI inventory path covered by this PR has no production callers.

Sign in to join this conversation.