Repository navigation
Closed
Description
Summary
The sst-dev.opencode-v2 (0.1.1) VS Code extension always spawns opencode serve on the fixed port 4096 and never kills it on deactivate, so every window reload orphans the server and the next panel open fails with Is port 4096 in use?.
Environment
- opencode version: 2.0.22
- OS: Linux pop-os 7.1.5-76070105-generic x86_64
- Terminal: TERM_PROGRAM=vscode, TERM=xterm-256color, COLORTERM=truecolor
- Shell: /bin/bash
- Install/channel: latest
- Active plugins: none configured (global config has 2 local MCP servers
jev/jev-paid, nopluginsentries; no project-local config)
Reproduction
- Install extension
sst-dev.opencode-v20.1.1 with opencode CLI 2.0.22. - Run
Open OpenCode Assistant(Ctrl+Esc). Extension spawnsopencode serve --hostname=127.0.0.1 --port=4096— panel opens fine. - Run
Developer: Reload Window(or restart VS Code). The spawnedserve --port=4096process survives (orphaned). - Run
Open OpenCode Assistantagain.
Expected Behavior
Extension reuses the existing server, kills the orphan before respawning, or picks a free port — panel opens.
Actual Behavior
Panel fails to open:
Failed to open OpenCode panel: Server exited with code 1
Server output: ServeError: ... {
[cause]: Error: Failed to start server. Is port 4096 in use?
}
opencode.log shows the second spawn failing while the first server is still alive and serving (returning 401 on /api/info as expected for an authed server):
timestamp=... run=e2c63ccc message="cli starting" args="[\"serve\",\"--hostname=127.0.0.1\",\"--port=4096\"]" role=cli
timestamp=... run=e2c63ccc message="Sent HTTP response" http.method=GET http.url=/api/info http.status=401
timestamp=... run=08d186c4 message="cli starting" args="[\"serve\",\"--hostname=127.0.0.1\",\"--port=4096\"]" role=cli
timestamp=... run=08d186c4 message="cli process failed" cause="Cause([Fail(ServeError (cause: Error: Failed to start server. Is port 4096 in use?))])" role=cli
ss/ps at failure time:
127.0.0.1:4096 LISTEN users:(("opencode",pid=590231,fd=10))
opencode serve --hostname=127.0.0.1 --port=4096 # orphan from previous session
Additional Context
- Extension source (0.1.1
dist/extension.js) hardcodes the port in two places:Be(d){d=Object.assign({hostname:"127.0.0.1",port:4096,timeout:5e3},d??{})...Be({port:4096,timeout:15e3,config:t})
deactivateonly disposes the webview panel, it never kills the spawned server process, so every reload leaks oneserveprocess (~150 MB).- Consistently reproducible (every reload).
- Local workaround verified: patch both occurrences to
port:0so the server picks a random free port (the extension already parses the real URL from stdout). Old servers still leak but the panel opens. Killing the orphan (kill <pid of opencode serve --port=4096>) before opening the panel also works for one session.
Metadata
Metadata
Assignees
Labels
No labels
Activity
guilhermespamplona-prog commentedon Oct 3, 2026
Update: encontrei uma segunda incompatibilidade que torna a extensão 0.1.1 inutilizável com a CLI 2.0.22 mesmo após resolver a porta.
O parser de startup em
dist/extension.js(Be()) espera:if(o.startsWith("opencode server listening"))mas a CLI 2.0.22 imprime:
Resultado: todo spawn novo sobe um servidor saudável e mesmo assim a extensão dá
Timeout waiting for server to start after 15000ms, orfanando um processoserve --port=0a cada tentativa. Workaround local: aceitar ambos os prefixos + usarport:0.guilhermespamplona-prog commentedon Oct 3, 2026
Update 2: após corrigir porta + parser, o painel quebra em
this.app.agents.forEach is not a function. Causa raiz: o SDK embutido (@opencode-ai/sdk ^0.6.10) chama 42 endpoints no path raiz (/agent,/session,/config,/tui/*...), mas a CLI 2.0.22 serve a API em/api/*—/agentretorna o HTML do web app, entãoe.datavem string e.forEachfalha. Ou seja, a extensão 0.1.1 é incompatível com a CLI 2.x em 3 camadas (porta fixa, prefixo de log, layout da API). Corrigir tudo localmente seria whack-a-mole; a extensão precisaria de um rebuild contra@opencode/client2.x.github-actions commentedon Oct 3, 2026
This issue might be a duplicate of existing issues. Please check:
For keybind-related issues, please also check our pinned keybinds documentation: #4997
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.