Repository navigation
Open
Description
Summary
On Windows with WSL2 in mirrored networking mode, the desktop app's background service (opencode-cli.exe serve --service) repeatedly fails to start: multiple concurrent spawns race for the fixed managed service port, failed spawns are surfaced as a fatal Desktop IPC handler failed error, and the app gets stuck at the logo. The underlying bind error is never logged to main.log.
Environment
- Desktop app: 2.0.29 and 2.0.30 (both affected)
- Bundled CLI: 2.0.29 / 2.0.30 (
opencode-cli.exe serve --service) - OS: Windows 11 Home x64 (build 10.0.26300)
- WSL: 3.0.3.0, distro Ubuntu (running), kernel 6.18.54.1-microsoft-standard-WSL2
.wslconfig:networkingMode=Mirrored+[experimental] hostAddressLoopback=true- A WSL-side shared service (
opencode serve --service, v2.0.30) runs inside the distro on127.0.0.1:49374; mirrored loopback (hostAddressLoopback=true) exposes it to Windows at127.0.0.1:49374
Reproduction
- Install the desktop app on a machine where the WSL distro runs the opencode shared service (or where the managed service port is otherwise occupied on Windows loopback)
- Launch the desktop app (cold start, or restart while the previous sidecar is still shutting down)
main.logshowsv2 CLI background service starting { reason: 'missing' }— repeated, with noservice ready- Windows-side service log shows repeated errors:
Managed service port <N> on 127.0.0.1 is already in use by another process. Configure another port with \opencode service set port ` ...` - App stuck at logo / error dialog:
Desktop IPC handler failed → Server process exited with code 1
Observed on both default ports:
- 2.0.29 (
49374): collides with the WSL-side service exposed on Windows loopback via mirrored networking - 2.0.30 (
45278): the app's own concurrent spawns race for the port — at least one instance binds and serves (visible in the log:/api/eventrequests served), while later duplicate spawns fail with45278 already in use;Service.ensuresurfaces the failed duplicate as fatal instead of adopting the serving instance
Expected Behavior
- Spawn attempts are serialized; a running compatible instance is adopted (or waited on) instead of racing
- If a spawn fails to bind, the underlying error is logged to
main.logand surfaced gracefully (window loads, connection retried) instead of a silent abort / stuck logo
Actual Behavior
Service.ensuretreats a failed spawn as fatal; the underlying bind error is never written tomain.log- App stuck at logo; error dialog:
UnknownError: An error occurred in Effect.tryPromise → Server process exited with code 1
Additional Context
- Workaround: an explicit free port in
%USERPROFILE%\.config\opencode\service.json({"port": <free>}) lets the service start - Related issues: Desktop: silent abort before window creation when sidecar utilityProcess.fork fails #49562 (silent abort without logging — same pattern), opencode2 became stuck starting its managed background server #41696, [v2 Windows] opencode2 hangs at "Starting background server..." after reinstall #41746
- Note: a fixed well-known service port also collides with WSL-side bindings under mirrored networking (
hostAddressLoopback=true), so a fixed port on Windows collides by design in this environment. Suggest considering an ephemeral service port + registration-file discovery, or excluding ports held by mirrored WSL bindings - Suggestion: log the failed spawn's underlying error in main.log — currently the one useful piece of information is the only thing never written anywhere (same as described in Desktop: silent abort before window creation when sidecar utilityProcess.fork fails #49562)
Metadata
Metadata
Assignees
Labels
No labels
Activity
opencode-agent commentedon Oct 16, 2026
Thanks for the detailed report and logs. I couldn't reproduce this here because it needs the Windows desktop app with WSL2 mirrored networking, which this sandbox can't provide. On Linux with 2.0.30, six
opencode service startruns at the same time all connected to one service without a port conflict. So the duplicate starts you saw probably come from the desktop app's startup path or from Windows itself, not the shared client. A maintainer with a Windows + WSL2 setup will need to look at it.Related issues, most closely related first:
serve --serviceon the fixed port while the existing service is still alive or bootingIn the meantime, setting a free port in
service.json(or withopencode service set port <port>), as you found, works around it.neriousy commentedon Oct 19, 2026
Thanks for the detailed report. Since 2.0.30 the Windows default port (45278) sits inside the usual WSL mirrored reservation (44620–48715), so we'd like to check whether that's part of what you saw:
wsl cat /proc/sys/net/ipv4/ip_local_port_rangewhile it fails.autoProxyin.wslconfig)?opencode service set port <port outside that range>(with the bundled CLI) fix it?zhangzp0127 commentedon Oct 20, 2026
感谢跟进。按你列的 4 点补充信息:
1) 2.0.32 上是否仍复现:
在 Desktop 2.0.29(默认 49374)和 2.0.30(默认 45278,来自 #55547)上均复现。2.0.32 未测——桌面在排查过程中被卸载,目前未安装,可以随时重装复测。
2) 临时端口范围:
默认服务端口 45278 正好落在这个范围内,与 #55918 的发现一致。
3) 代理:
未配置任何代理——Windows 系统代理
ProxyEnable=0,.wslconfig中无autoProxy,也未设置HTTP(S)_PROXY环境变量。4)
service set port修复测试:尚未用桌面内置 CLI 实测
opencode service set port <port outside range>(桌面已卸载)。但等效方案已验证有效:在%USERPROFILE%\.config\opencode\service.json显式指定范围外端口({"port": 49376})后,服务可正常启动,桌面恢复可用。补充一点:#55918 的独立绑定测试(.NET TcpListener 直接绑定 45278 失败、无任何进程占用、邻近端口正常)与我们观察到的现象完全吻合,支持“镜像模式 HNS 临时端口预留”这一根因判断。如果需要,我可以重装桌面 2.0.32 并实测
service set port的修复效果后回来同步结果。fix(cli): scope managed service port remap to WSL with distinct default