Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Opencode server frequently disconnects / connection lost #2579

Closedfadilsflow(GitHub profile, opens in a new tab) opened this issue 1 comment

Description

When using opencode as a provider in t3code, the connection to the opencode server frequently drops/disconnects. Sessions suddenly die with no automatic reconnection.

Root Cause (from source code analysis)

  1. No reconnect logic - t3code spawns opencode serve as a child process. When that process crashes or exits, the session dies immediately with no auto-restart. (apps/server/src/provider/Layers/OpenCodeAdapter.ts)

  2. SSE event stream is fragile - Real-time communication uses Server-Sent Events (long-lived HTTP streaming) with no heartbeat/keepalive mechanism.

  3. Short startup timeout (5 seconds) - DEFAULT_OPENCODE_SERVER_TIMEOUT_MS = 5000. If the server is slow to start (e.g., due to many plugins/MCP/LSP servers), it times out.

  4. Text generation server idle TTL of 30 seconds - OPENCODE_TEXT_GENERATION_IDLE_TTL = "30 seconds". The shared server is killed after 30 seconds of inactivity. (apps/server/src/textGeneration/OpenCodeTextGeneration.ts)

  5. No clear error message in UI - Users only see "disconnected" without knowing the actual cause.

Environment

  • t3code version:
  • opencode version:
  • OS:

Steps to Reproduce

  1. Open t3code, select opencode as provider
  2. Start a session and use it for a while
  3. Let it sit idle, or just let the server run
  4. Session suddenly disconnects / connection lost

Expected Behavior

  • Stable connection or auto-reconnect when disconnected
  • Clear error messages when something goes wrong
  • Server should not be killed after short idle periods

Additional Context

Related issues: #2378 (t3code should resume same conversation after idle timeout)

  1. Closing as a duplicate of #2644, which is the canonical OpenCode disconnect/SSE-lifecycle report. PR #2908 previously attempted the shared fix but closed unmerged; there is currently no active superseding PR, so future implementation should stay attached to #2644.

  2. juliusmarminge added labelsduplicate

  3. juliusmarminge closed this

Sign in to join this conversation.