Repository navigation
Description
Summary
The OpenCode Beta VS Code extension (sst-dev.opencode-v2, v0.1.1) spawns its
backend with a hardcoded port:
opencode serve --hostname=127.0.0.1 --port=4096
(ServerManager.startServer calls createOpencodeServer({ port: 4096, ... }), and
the SDK default client is baseUrl: "http://localhost:4096".)
Because the port is explicit, Server.listen takes the no-fallback path
(startWithPortFallback: if (opts.port !== 0) return startListener(opts, opts.port)),
so if 4096 is already bound, the server exits with code 1 and the panel fails with:
Failed to open OpenCode panel: Server exited with code 1
Server output: Warning: OPENCODE_SERVER_PASSWORD is not set; server is unsecured.
Error: Unexpected error
ServeError
(The useless last line is a separate, already-reported bug: #38738, #46263.)
Steps to reproduce
- Occupy port 4096 with anything:
nc -l 4096, or- an
opencode acpsession (e.g. Zed's opencode agent integration), or opencode web/opencode serve, or- the OpenCode panel in another VS Code window
- In VS Code, click the OpenCode activity-bar icon (or run "Open OpenCode Assistant").
- Panel fails with the error above.
Expected behavior
The extension should let the opencode process select the port itself instead of
pinning 4096. The CLI already implements the ideal behavior for a default port:
startWithPortFallback tries 4096 and falls back to any free port
(startListener(opts, 4096) |> Effect.catch(() => startListener(opts, 0)))
— this is why multiple opencode acp sessions coexist fine. Passing --port=0
would give the extension that behavior for free, the port is bound atomically by
the server process (no scan-then-bind race on the extension side), and
createOpencodeServer already parses the actual server URL back from stdout, so
the extension machinery for a dynamic port is already in place.
Alternatively, attach to an already-running compatible server (see #7629) instead of
spawning a new one.
Impact
- Only one VS Code window can ever use the panel at a time (each window's
extension host spawns its own server on the same fixed port). - The panel cannot coexist with Zed's opencode ACP agent, the desktop app, or a
manualopencode serve/web— whoever starts first wins, everyone else gets an
opaqueServeError. - Closing the panel tab doesn't even free the port; the server outlives the webview
(onDidDisposeonly clears the panel reference), so a window reload is required.
Environment
- Extension:
sst-dev.opencode-v2v0.1.1 - opencode CLI: 1.18.30 (homebrew, macOS arm64)
- VS Code: 1.137.0
Related
- opencode serve: bind failures print bare "Unexpected error / ServeError" — the listen errno is never surfaced #38738 — bind failures print bare "Unexpected error / ServeError"
- CLI: web and serve show generic error message when the port is already in use #46263 — generic error when port is already in use
- ACP Fails miserably when there's another session elsewhere #39390 — ACP failing on second session (fixed by the port fallback; the extension
should get the same treatment) - [Enhancement] Desktop app and terminal should connect to existing server instead of starting a new one when port is already in use #7629 — connect to existing server instead of starting a new one
Activity
rekram1-node commentedon Oct 14, 2026
The "OpenCode Beta" extension (sst-dev.opencode-v2) is no longer maintained and won't be updated for V2. Please use the main opencode extension (sst-dev.opencode) v1.0.0 instead, which works with the V2 CLI. Closing.