Skip to content

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

Closed as duplicate

Description

@fadilsflow

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)

Activity

  1. changed the title [-][Bug]: Opencode server sering disconnect / connection lost[/-] [+][Bug]: Opencode server frequently disconnects / connection lost[/+] on May 7, 2026
  2. juliusmarminge commented on Jul 20, 2026

    @juliusmarminge
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions