Repository navigation
WSL2: server event-loop deadlock (zombie git children) when Desktop app bootstraps multiple instances concurrently; drvfs project amplifies #36840
Description
Summary
On WSL2, opencode serve deadlocks (event loop stops entirely) when the Desktop app connects and the server bootstraps instances for multiple project directories at roughly the same time. The process stays alive and the port stays in LISTEN, but it never accepts connections again (backlog fills up), and it leaves <defunct> (zombie) git child processes that are never reaped.
The same server, receiving the same bootstraps one at a time, works fine. Running the server under strace -f also makes the hang disappear, which points to a timing-dependent race in child-process handling rather than a logic error.
A project directory on a 9p/drvfs mount (Windows drive mounted into WSL, where git is much slower) makes the hang far more likely — in my case it reproduced 3 out of 3 times on Desktop connect when a drvfs-mounted project was in the recent-projects list.
Environment
- opencode 1.17.18 (installed via npm, Linux x64 build inside WSL)
- WSL2, Ubuntu 24.04, Windows 11 Pro 10.0.26100
- Server started with:
opencode serve --hostname 127.0.0.1 --port 4096 - Client: OpenCode Desktop app on Windows, connecting to
http://localhost:4096 - One project directory is a Windows drive mounted via 9p/drvfs (
D:\workspace→/workspace), a git repo with ~20k files
Symptom details
When the hang occurs:
-
ss -tlnpshows the port still listening, with the accept backlog growing and never draining:LISTEN 12 512 127.0.0.1:4096 0.0.0.0:* users:(("opencode",pid=9097,fd=17)) -
curl http://127.0.0.1:4096/appfrom inside WSL times out (45s+, no response at all). -
The opencode process has zombie git children that are never reaped (so git itself finished — the parent just never processed the exit):
$ ps --ppid <opencode-pid> -o pid,stat,cmd --no-headers 14582 Zs [git] <defunct> 14583 Zs [git] <defunct> 14584 Zs [git] <defunct> 14590 Zs [git] <defunct> -
Server log stops mid-bootstrap. In the hang below, the Desktop app connect triggered two instance creations ~3ms apart; the
/homeinstance completed bootstrap, the/workspace(drvfs) instance loggedfromDirectoryand then nothing:09:37:13.964 INFO run=f19ba75d message="creating instance" directory=/home/l00959355 09:37:13.965 INFO run=f19ba75d message=fromDirectory directory=/home/l00959355 09:37:13.967 INFO run=f19ba75d message="creating instance" directory=/workspace 09:37:13.967 INFO run=f19ba75d message=fromDirectory directory=/workspace 09:37:13.987 INFO run=f19ba75d message=bootstrapping directory=/home/l00959355 09:37:14.070 INFO run=f19ba75d message=init <-- /home instance only; no "bootstrapping directory=/workspace" ever appearsAfter this point the server answers nothing — not even requests for the already-initialized instance.
What I ruled out
- Not WSL networking: a healthy
opencode serveon another port is reachable from Windows via localhost forwarding instantly (HTTP 200). - Not 9p traversal in general:
find /workspace(20k files) over 9p completes fine; plaingit statusin that directory completes in seconds. - Not repo content: a minimal fresh git repo on the same 9p mount bootstraps fine (HTTP 200). Adding Linux symlinks and a unix socket to it (which the real repo contains) still fine.
- Not deterministic: 5/5 rounds of "start server + single
GET /appbootstrap" succeeded in the drvfs directory and in an ext4 clone of the same repo. The hang appears specifically when the Desktop app connects and multiple instances bootstrap concurrently — that reproduced 3/3. - Heisenbug: with
strace -fattached, the exact same startup in the drvfs directory bootstraps and serves normally.
Hypothesis
Race in subprocess reaping/await in the runtime under concurrent instance bootstrap: when several git children (slow on 9p, so exits land at "unusual" times) exit close together during parallel bootstraps, the event loop deadlocks waiting on child results that were already delivered, leaving zombies and a dead HTTP server.
Possibly related: #2692 (opencode run hangs on WSL, closed as dup of #1431), #1431 (child processes not terminating), #28799 / #30230 (Desktop↔WSL connect problems — same user-visible symptom, "cannot connect", since the hung server times out every connection).
Repro (best known)
- WSL2 with a git repo on a drvfs mount (Windows drive), ideally a real repo with a few thousand files.
opencode serve --hostname 127.0.0.1 --port 4096inside WSL (any cwd).- Connect the Windows Desktop app to
http://localhost:4096with the drvfs project (plus at least one other directory) in the recent-projects list, so it bootstraps multiple instances on connect. - Server deadlocks during bootstrap; check
ss -tlnpbacklog andps --ppid <pid>for[git] <defunct>.
Activity
Moler1995 commentedon Jul 30, 2026
Same issue on my linux server with
opencode runcommand.github-actions commentedon Sep 30, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.