Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): bound OpenCode version probes #8750

Mergedyashranaway(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/8750/headmerged by juliusmarminge View on GitHub

What Changed

  • Stop local OpenCode version probes after four seconds.
  • Spawn probe commands in a process group on POSIX hosts.
  • Kill the full probe group when its scope closes.
  • Add coverage for a version command that never returns.

Why

A hanging OpenCode wrapper could leave provider discovery running indefinitely and retain CPU-heavy descendants.

Closes #8681

Testing

  • pnpm exec vp test run apps/server/src/provider/Layers/OpenCodeProvider.test.ts apps/server/src/provider/opencodeRuntime.inventory.test.ts
  • pnpm exec vp run --filter t3 typecheck
  • pnpm exec vp lint apps/server/src/provider/opencodeRuntime.ts apps/server/src/provider/Layers/OpenCodeProvider.ts apps/server/src/provider/Layers/OpenCodeProvider.test.ts

Checklist

  • One focused behavior change
  • Focused regression coverage
  • Formatting and lint pass

Model: GPT-5.6 Sol Harness: Codex in T3 Code


Note

Medium Risk Touches process spawn/teardown and provider health checks; mis-kill logic could affect unrelated processes on POSIX, but scope is limited to OpenCode CLI invocations.

Overview OpenCode provider discovery no longer blocks forever when the local opencode --version health check hangs. The version probe is capped at 4 seconds; on timeout the check returns an error snapshot with a clear timeout message.

To avoid orphaned CLI processes when the probe is cancelled or times out, local command spawns on POSIX use a detached process group and a scope finalizer that SIGKILLs the whole group (Windows still kills the child directly). Tests add a hanging-CLI mock and a TestClock case that asserts the timeout path.

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

Note

Bound OpenCode CLI version probe with 4-second timeout and force-terminate spawned process

  • Wraps runOpenCodeCommand(--version) in checkOpenCodeProviderStatus with Effect.timeoutOrElse using the new OPENCODE_VERSION_PROBE_TIMEOUT constant (4 seconds), failing with a timeout-specific OpenCodeProbeError when the probe hangs
  • Makes OpenCodeProbeError.cause optional so timeout errors can be constructed without an underlying throwable
  • Adds a finalizer to makeOpenCodeRuntime.runOpenCodeCommand that sends SIGKILL to the child (Windows) or the negative child PID (non-Windows, process group) when the effect scope ends, ignoring errors if the process already exited
  • Risk: runOpenCodeCommand now sets detached=true on non-Windows platforms; out-of-tree callers relying on the child sharing the parent process group may see different process-group behavior
Macroscope summarized 600c95c.
    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: ef32cbcf-dc0f-4ccd-81e3-cbc48580186e

      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

      Warning

      Your free Security trial is over. An organization admin can activate Security or dismiss this notice.


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

    3. Effect service conventions review: one finding on the new timeout failure construction in apps/server/src/provider/Layers/OpenCodeProvider.ts. The process-group cleanup in opencodeRuntime.ts follows the existing pattern in startOpenCodeServerProcess and the added timeout test is appropriately focused.

      Posted via Macroscope — Effect Service Conventions
    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 600c95c

      Macroscope's review found this PR approvable — This is a focused server bug fix that caps hanging local OpenCode version probes at four seconds and cleans up their process groups without changing normal successful paths. The affected runtime behavior is narrowly scoped to internal OpenCode CLI probes, with regression coverage for the timeout case.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Verified on Windows 11, Node 22.14.0 (repo asks ^24.13.1), pnpm 11.10.0, fork CDVolvik/t3code, no push.

      On pr-8750 (600c95ce) \pnpm exec vitest run apps/server/src/provider/Layers/OpenCodeProvider.test.ts\ — 13/13 pass, including the new \ imes out a hanging local CLI version probe\ at OpenCodeProvider.test.ts:225 which forks the check with
      unVersionPending:true\ (Effect.never) and TestClock.adjust(4 seconds) then asserts \Failed to execute OpenCode CLI health check: OpenCode CLI version probe timed out after 4 seconds.\ \pnpm exec vitest run apps/server/src/provider/opencodeRuntime.inventory.test.ts\ — 5/5 pass; combined 18/18. Typecheck passes. Lint plugin load failed on this Node — env, not patch.

      Reverting only OpenCodeProvider.ts and opencodeRuntime.ts to main (2daff8c25) while keeping the new test makes that test time out in 3000ms (Test timed out in 3000ms at 225), so it does cover the regression; with the fix restored it passes in 6ms. This matches issue #8681: on main the runOpenCodeCommand at OpenCodeProvider.ts:393 has no bound.

      Fix is surgical: OpenCodeProvider.ts:34 defines OPENCODE_VERSION_PROBE_TIMEOUT=4 seconds and 403 wraps the version probe in timeoutOrElse returning OpenCodeProbeError; opencodeRuntime.ts:558 detached: hostPlatform !== win32 and 564 scoped finalizer SIGKILLs the child/group.

      Unit-level only. POSIX detached + kill(-pid) path was code-reviewed but not exercised on Windows — tests mock OpenCodeRuntime and use TestClock. Did not reproduce Arch mise wrapper hang end-to-end.

      LGTM on the mocked path; disclosure: Node 22 vs required 24.

    6. juliusmarminge merged this4116db9

    7. juliusmarminge closed this

Sign in to join this conversation.