Repository navigation
Description
Environment
- OpenCode Desktop 2.3.0 (win32 x64), bundled CLI 2.3.0
- Windows (x64), Wi-Fi, RU ISP with DPI filtering (Happ TUN enabled)
- The failing session's workspace is the filesystem root (
C:\)
Summary
On Desktop 2.3.0 the managed background service (opencode-cli serve --service, 127.0.0.1:28894) is repeatedly detected as "missing" and restarted by the main process. Every restart drops in-flight requests, so the UI shows ClientError: Transport: Failed to fetch, ClientError: Transport: network error and ECONNRESET: The socket connection was closed unexpectedly.
The service itself is healthy: when started manually it stays up indefinitely and answers /api/info. Only the app-managed instance dies or gets restarted.
Steps to reproduce
- Start OpenCode Desktop 2.3.0, open a session whose workspace is
C:\(very large tree). - Leave the app idle for ~30 s.
- Observe UI errors and repeated service restarts.
Evidence (from %APPDATA%\ai.opencode.desktop\logs\<session>\)
main.log (repeats every 10-30 s):
[info] (main) starting v2 background service
[info] (main) v2 CLI background service starting { reason: 'missing' }
[info] (main) v2 CLI background service ready { runningVersion: '2.3.0', probed: false, ... }
renderer.log:
[info] [global-sdk] event stream disconnected (exactly every 10.000 s)
[error] ClientError: Transport: network error
[error] ClientError: Transport: Failed to fetch
[warn] [server-request-queue] server thrashing detected
[error] Failed to read server terminal support ClientError: UnexpectedStatus: 503
[error] Failed to list terminals Error: The server took too long to answer
opencode.log:
level=ERROR message="failed to fetch models.dev" ... operation timed out after '10s'
level=INFO message="location services booted" durationMs=18481
Control tests performed
opencode-cli.exe serve --port 28894(manual, standalone): runs >100 s without exit;/api/inforesponds.opencode-cli.exe serve --service --port 28894 --log-level debug: runs >100 s without exit.opencode-cli.exe service start+service status=> service running and responding.- Disabling all global plugins in
~/.config/opencode/pluginsdoes not stop the restart loop. - Launching the app with
--no-proxy-serverdoes not stop it. - Duplicate spawns produce
Failed to start server. Is port 28894 in use?in the same window.
Root cause hypothesis
Two independent effects:
- The SSE stream
/api/eventis closed by the server every 10 s (BunidleTimeoutdefault), which the client treats as a transport failure. - When a renderer request fails during service boot (503 while "location services" boot for a huge workspace), the main-process supervisor restarts the background service; each restart kills in-flight requests and produces the user-visible "connection closed" errors. With a large workspace boot takes 10-20 s, so the loop never converges.
Expected
- No service restarts while the service is healthy; SSE reconnects should not be treated as fatal.
- Either a configurable service-start timeout, or readiness should be probed until boot completes.
Related
#60399 covers model requests failing due to RU ISP DPI (ECONNRESET). It explains the error text but not this local supervisor loop: the loop reproduces with a working network path, and the service answers fine when run manually.
Activity
opencodejr commentedon Nov 15, 2026
Thanks for the detailed logs and control tests. I couldn't reproduce this here: the restart loop comes from the Windows desktop app's supervisor, and my sandbox is Linux-only with no desktop build.
What I could check, with the 2.3.0 CLI on Linux:
/api/event, both fromopencode serveand from the managed service started withopencode service start, sentserver.connectedand then a heartbeat every 15 s, and stayed open for the 40-45 s I watched. I did not see the server close it after 10 s. So the disconnect every 10 s in yourrenderer.logmay come from something else, such as the app reconnecting or something between the app and127.0.0.1./api/infokept returning 200 and the service kept the same PID. But the root here is tiny compared withC:\: it booted in about 1 s, not the ~18 s in your log, so I couldn't recreate the slow boot.These would help a maintainer with a Windows setup:
errorfield of the[global-sdk] event stream disconnectedconsole entry.opencode-cli serve --serviceprocess keeps the same PID across thereason: 'missing'lines, or a new process starts each time.C:\.Related issues, most likely first:
reason: 'missing'in a loop, interrupting workA maintainer with a Windows environment will need to look at this.
zigih-1212 commentedon Nov 15, 2026
Thanks. Here is the additional data you asked for, collected on Windows 11 (desktop 2.3.0) while the loop was running.
1. PID stability across
reason: 'missing'events — a new PID every cycleSampling
Get-NetTCPConnection -LocalPort 28894andGet-Process opencode-clievery 2 s:Each
opencode-clilives only ~5–10 s, and the PID changes on every spawn. Correlatedmain.log:Control: the same executable, same port, started outside the app, is stable and keeps the same PID:
opencode-cli.exe serve --port 28894— >100 s,/api/infoanswers;opencode-cli.exe serve --service --port 28894 --log-level debug— >100 s;listenPid=6308constant) while the desktop app was open, and disappeared only when the app was restarted.So the child process is healthy, but as soon as it is app-managed it is replaced every ~11 s.
2. The error field of
[global-sdk] event stream disconnectedNot captured.
renderer.logonly records[object Object]; the DevTools console is not reachable from a script. If you tell me which console filter or how to dump the entry (or if the log call canJSON.stringifythe argument), I will paste it.3. Small project folder instead of
C:\Not tested through the UI yet (the app has to open a folder interactively). What I can confirm is the boot cost difference with the same CLI:
location services booted durationMsis ~1000–1800 ms for a small folder vs 18481 ms forC:\. I can run the UI test on request.4. Loop with Happ TUN off
Not tested: without the tunnel, model requests to
opencode.ai/models.devare RST by the ISP here (the #60399 condition), so the test would mix two failures. The loop itself is local (127.0.0.1) and reproduces whilecurl --noproxy "*" http://127.0.0.1:28894/api/inforeturns 401 immediately.Notes
Transport: network error— that is the user-visible "socket connection was closed unexpectedly".main.log,renderer.logandopencode.logfor this session if that helps.zigih-1212 commentedon Nov 15, 2026
Additional data from the same Windows machine (desktop 2.3.0, CLI 2.3.0), trying to find a mode that survives:
1. Managed service (default TUI)
The TUI spawns
serve --serviceroughly every 9–11 s:The listening socket on 28894 flaps in and out between spawns, and the TUI shows a permanent overlay:
2.
--standalone(private server)The TUI starts a private
serve --stdio --port 0, which exits shortly after start. The client then loops on ECONNREFUSED once per second:UI shows
connection lost / Reconnecting to the servers automatically. Nolevel=ERRORfrom the server itself — the child simply disappears.3. Pre-started service + plain TUI
opencode-cli service startalone is stable: the process keeps the same PID for 30+ minutes and answersservice status.If the TUI is started while that service is already running, the TUI attaches, but within ~3 minutes the supervisor spawned
serve --servicetwice and the original stable process was gone.4.
--server <url>opencode-cli --server http://127.0.0.1:28894fails immediately:There is no documented flag or environment variable to pass that password to
--server(serve --helphas no auth flag), so this path is unusable as a workaround.Conclusion
The service binary itself is healthy — it survives indefinitely when nothing supervises it. The failure appears whenever a TUI client is attached: the client's lifecycle logic kills/replaces the server (managed and standalone alike) within ~10 s, which is also the observed cadence of the
serve --servicerespawns. This points at the supervisor/readiness logic rather than at the server, config, plugins or the network.If a maintainer can reproduce on Windows, the interesting question is: why does the app-spawned
serve --service/serve --stdioprocess exit after ~5–10 s while the same binary started directly from the shell lives for minutes?jerry155756294 commentedon Nov 17, 2026
@zigih-1212 https://opencode.ai/docs/migrate-v1/