Skip to content

WSL2: server event-loop deadlock (zombie git children) when Desktop app bootstraps multiple instances concurrently; drvfs project amplifies #36840

Closed as not planned

Description

@zihanlin-ai

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 -tlnp shows 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/app from 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 /home instance completed bootstrap, the /workspace (drvfs) instance logged fromDirectory and 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 appears
    

    After this point the server answers nothing — not even requests for the already-initialized instance.

What I ruled out

  • Not WSL networking: a healthy opencode serve on 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; plain git status in 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 /app bootstrap" 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 -f attached, 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)

  1. WSL2 with a git repo on a drvfs mount (Windows drive), ideally a real repo with a few thousand files.
  2. opencode serve --hostname 127.0.0.1 --port 4096 inside WSL (any cwd).
  3. Connect the Windows Desktop app to http://localhost:4096 with the drvfs project (plus at least one other directory) in the recent-projects list, so it bootstraps multiple instances on connect.
  4. Server deadlocks during bootstrap; check ss -tlnp backlog and ps --ppid <pid> for [git] <defunct>.

Activity

  1. Moler1995 commented on Jul 30, 2026

    @Moler1995

    Same issue on my linux server with opencode run command.

  2. github-actions commented on Sep 30, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions