Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: OpenCode marked unavailable on first launch after reboot: 4 s version probe is too tight on Windows #12973

ClosedComprehensive-Jason(GitHub profile, opens in a new tab) opened this issue 2 comments

Before submitting

  • I searched existing issues and did not find a duplicate. (#2163 is a PATH resolution problem, not a timeout; #8681 is the hang this bound was added for.)
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Windows 11, OpenCode 1.18.x installed from npm (opencode-ai); opencode --version works in any shell.
  2. Reboot, sign in, open T3 Code within the first few minutes.
  3. Open Settings > Providers. OpenCode shows as unavailable.
  4. Click Refresh on the OpenCode provider. OpenCode is now available and works normally.

Setting "Binary path" to the direct exe (...\npm\node_modules\opencode-ai\bin\opencode.exe, skipping the npm .cmd shim) does not change the outcome.

Expected behavior

OpenCode is detected on the first launch after a reboot, or the probe retries before the provider is marked unavailable.

Actual behavior

checkOpenCodeProviderStatus in apps/server/src/provider/Layers/OpenCodeProvider.ts runs opencode --version under OPENCODE_VERSION_PROBE_TIMEOUT = "4 seconds" (added in #8750). On Windows the OpenCode binary is a 180 MB Bun executable, and --version alone costs (stopwatch around the exe only, no shell wrapper):

Conditionopencode --version wall time
Warm, machine idle~600 ms
Warm, machine under load1.5 to 2.6 s
First run of a freshly written binary (not yet in file cache, plus Defender first-execution scan)3.69 s
Fresh copy of an already-cached exe (isolates the Defender scan)+~200 ms

The freshly written binary is the same situation as the first launch after a reboot, and it lands within 0.3 s of the bound on a machine that is otherwise idle. Add the startup-app contention right after sign-in and it goes over; once the file is cached, a manual Refresh passes, which is why the symptom only shows on the first launch of the day.

Isolation tests that made no difference: pointing XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_CACHE_HOME, and XDG_STATE_HOME at empty directories (no config, plugins, skills, or session DB). The cost is the binary's own startup, not the user's OpenCode setup.

Proposed fix (happy to open a PR)

Retry the version probe on timeout rather than raising the bound. A cold start is a one-time cost: even when the first attempt is killed at 4 s, the pages it read stay in the file cache, so the second attempt runs at warm speed and passes. Concretely, in checkOpenCodeProviderStatus:

  • Wrap the --version probe in Effect.retry with a schedule of two more attempts (three total) and a short fixed delay (~500 ms), retrying only on the timeout branch of OpenCodeProbeError. ENOENT, an unparsable version, and a too-old version keep failing immediately.
  • Leave OPENCODE_VERSION_PROBE_TIMEOUT at 4 s per attempt, so the #8681 hang case still ends within 12 s worst case instead of blocking discovery for a longer flat bound.
  • Extend the existing hanging-CLI test in OpenCodeProvider.test.ts with a mock that times out once and then answers, asserting the provider ends up ready.

A flat 15 s bound would also work but has worse trade-offs: it holds a genuinely hung wrapper for 15 s every time, and it still fails on any single cold run that exceeds it. If maintainers prefer a bound change I can do that instead, or both.

Impact

Minor bug or occasional failure

Version or commit

0.0.44 nightly line, build dated 2026-09-15 (bundle contains the #8750 change). The 4 s bound is still on main as of 2026-09-21.

Environment

Windows 11 Home 10.0.26200, 16 GB RAM, NVMe SSD, Windows Defender real-time protection on. OpenCode 1.18.31 and 1.18.32 via npm.

Logs or stack traces

Provider status message shown in the UI on the failed probe: "OpenCode CLI version probe timed out after 4 seconds." (from checkOpenCodeProviderStatus).

  1. Duplicate of #11080 — same root cause: the hardcoded 4s OPENCODE_VERSION_PROBE_TIMEOUT marks OpenCode Unavailable on a cold/slow --version probe (Windows Defender / first-launch here; wrapper cold cache there).

    Tracking continues on #11080. Open PR #12701 raises the bound and keeps a prior ready snapshot across a single timeout.

  2. juliusmarminge added labelsduplicate

  3. juliusmarminge closed this

  4. Awesome that someone's found this already, thanks for letting me know!

Sign in to join this conversation.