GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Desktop WSL sidecar fails with ServeError when networkingMode=mirrored · Issue #37718 · anomalyco/opencode

Desktop WSL sidecar fails with ServeError when networkingMode=mirrored #37718

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Desktop WSL sidecar fails with ServeError when networkingMode=mirrored#37718
Copy link
Assignees
Hona

Description

@Amamiya23
Amamiya23
opened on Jul 19, 2026
Issue body actions

Description

OpenCode Desktop's managed WSL server consistently fails to start when WSL2 uses mirrored networking. The Desktop recognizes the distro and native Linux binary correctly, but the sidecar exits before health checking with only:

Error: Unexpected error
ServeError

This appears to be a port-allocation handoff issue in packages/desktop/src/main/wsl/sidecar.ts: allocatePort() reserves an ephemeral port on Windows, closes it, and then asks WSL to bind 0.0.0.0 on the same port. With networkingMode=mirrored, Windows and WSL share the port space, and the immediate WSL bind fails.

I reproduced the same allocation sequence independently 8 times; all 8 attempts failed with the identical Unexpected error / ServeError. Starting the same WSL binary directly on a known free fixed port succeeds.

Plugins

None in the WSL config.

OpenCode version

Desktop and WSL binary: 1.18.3

Steps to reproduce

  1. Configure %USERPROFILE%\.wslconfig:

    [experimental]
    networkingMode=mirrored
    dnsTunneling=true
    autoProxy=true
  2. Run wsl --shutdown, then start OpenCode Desktop.

  3. Add an installed WSL2 distro as a managed WSL server.

  4. Observe that the server repeatedly fails before becoming healthy.

Desktop log:

wsl sidecar starting { id: 'wsl:Ubuntu-24.04', distro: 'Ubuntu-24.04' }
wsl sidecar { distro: 'Ubuntu-24.04', stream: 'stderr', text: 'Error: Unexpected error' }
wsl sidecar { distro: 'Ubuntu-24.04', stream: 'stderr', text: 'ServeError' }
wsl sidecar failed to start {
  message: 'WSL server exited before becoming healthy (code=1 signal=null)'
}

Control test that succeeds:

~/.opencode/bin/opencode serve --hostname 0.0.0.0 --port 4096

Expected: the managed WSL sidecar starts while mirrored networking remains enabled.

A possible fix would be to allocate the port from inside WSL, let opencode serve --port 0 report its selected port, or retry when the cross-environment port handoff fails.

Operating System

Windows 11 25H2 build 26200.8875; WSL 2.9.3.0; Ubuntu-24.04 distro.

Terminal

OpenCode Desktop managed WSL server (reproduced independently from PowerShell).

Reacted by Hashvin K and Rózsa Zoltán

Activity

  1. github-actions
    assigned
    Hona
    on Jul 19, 2026
  2. dzianisv commented on Jul 24, 2026

    @dzianisv
    dzianisv
    on Jul 24, 2026
    More actions

    Root cause of the opaque Error: Unexpected error / ServeError output here is tracked in #38738 — Effect's ServeError is a Data.TaggedError with an empty message, and opencode's errorMessage() never reads .cause, so the real listen errno is dropped.

    Relevant to your mirrored-networking diagnosis: under Bun, node:http listen() reports every failure as EADDRINUSE (#38739) — verified against Node, which correctly returns EADDRNOTAVAIL / EACCES for the same binds. So the WSL sidecar failure may not be a port conflict at all; the errno cannot distinguish it. With #38738 applied the sidecar would print the actual cause instead of ServeError, which should settle it either way.

  3. dzianisv
    added a commit that references this issue on Jul 24, 2026

    fix(serve): surface the real bind error instead of "Unexpected error …

    763cecd
  4. Rokurolize commented on Aug 14, 2026

    @Rokurolize
    Rokurolize
    on Aug 14, 2026
    More actions

    Additional observation, now with the command-line client (opencode2, v2 preview) in the same environment (Windows 11, WSL2 with mirrored networking).

    The v2 CLI background service fails to start for the same reason, and it shows a clean boundary:

    • Binding a listening socket from WSL to any port 49152 or higher always fails with "Address already in use" (tested 49152, 49374, 50060, 51000, 60000, 65535).
    • Binding to any port below 49152 succeeds (tested 48716, 49000, 49151).
    • Windows reports its dynamic TCP port range as 49152-65535 (netsh int ipv4 show dynamicport tcp), and netstat -ano showed nothing actually listening on the failing ports.

    So from inside WSL with mirrored networking, the whole Windows dynamic port range appears to be unavailable, even when no other process uses the port.

    The v2 CLI hits this because its managed background server uses a fixed default port of 49374 (hard-coded as 0xc0de in service-config.ts of the shipped binary), which falls inside that range. On every launch the client spawned the server, the server failed to bind that port and exited, and the client silently started it again in a loop ("Starting background server..." with no visible error).

    A workaround that works: opencode2 service set port 48716 (any free port below 49152). After that, the background server binds, its health endpoint reports healthy, and the client connects normally.

    Since the failing range starts exactly at 49152, keeping managed-service default ports below the Windows dynamic range (or letting the service pick a free port) would avoid this failure mode entirely.

  5. github-actions commented on Oct 14, 2026

    @github-actions
    github-actionsBot
    on Oct 14, 2026 – with GitHub Actions
    Contributor
    More actions

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

  6. github-actions
    closed this as not plannedon Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @Hona
    Hona

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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.