anomalyco / anomalyco/opencode

[global-sdk] event stream failed race condition on startup and after config hot-edit causes UI to hang indefinitely

Open
#41,986 2 comments 0 reactions 1 assignee View on GitHub

@Hona is already working on this.

Since Aug 12, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Bug Description

After starting opencode or after editing opencode.json, the renderer logs show:

[error] [global-sdk] event stream failed [object Object]

This occurs ~281ms after server ready is logged in main.log. The UI displays "Reasoning" animation but no request is ever sent to the AI server. The only way to recover is to resend a message or create a new chat, which re-establishes the connection.

Steps to Reproduce

  1. Start opencode (or edit opencode.json while running)
  2. Send any message in a chat
  3. UI shows "Reasoning" spinner indefinitely
  4. Check renderer.log: [global-sdk] event stream failed [object Object]
  5. No HTTP request reaches the configured AI server

Expected Behavior

The SDK should retry establishing the event stream automatically, or wait for sidecar to be fully ready before attempting connection.

Actual Behavior

Connection fails silently on first attempt. UI state is not synchronized with actual connection status. User must manually "kick" by resending message or creating new chat.

Environment

  • opencode version: 1.18.16 (Tauri desktop)
  • Platform: Linux (Ubuntu/Debian)
  • Provider: custom OpenAI-compatible (@ai-sdk/openai-compatible)
  • Sidecar URL: http://127.0.0.1:46137

Logs

main.log:

[info] awaiting server ready
[info] server ready { url: "http://127.0.0.1:46137" }

renderer.log (281ms later):

[error] [global-sdk] event stream failed [object Object]

Root Cause Analysis

Race condition between sidecar server ready event and SDK initialization. The renderer attempts to establish an event stream before the internal connection pool is fully initialized, especially after config hot-edit when sidecar restarts but renderer does not receive a proper readiness notification.

Suggested Fix

  • Add retry logic with exponential backoff for [global-sdk] event stream failed errors
  • Ensure renderer waits for a confirmed ready state from sidecar before attempting SDK initialization
  • Sync UI "Reasoning" state with actual connection status to prevent indefinite spinner when connection is down

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.