Repository navigation
Description
Summary
Running opencode in several VS Code integrated terminal tabs and switching between those tabs makes opencode stop responding. With multiple instances attached, they stall together. Claude Code in the same setup does not — it has no shared background service.
Environment
- opencode version: 2.0.29 (
channel=latest local=false) - OS: macOS 27.0.1 (arm64), kernel 27.0.0
- Terminal: VS Code integrated terminal (
TERM_PROGRAM=vscode,TERM=xterm-256color) - Shell:
/bin/zsh - Install: managed binary,
~/.opencode/bin/opencode
Steps to reproduce
- Open VS Code with several integrated terminals.
- Run
opencodein each one (same project or different projects). - Switch between the terminal tabs, or switch away from VS Code and back.
- opencode becomes unresponsive — keystrokes are accepted but no output is rendered, or the pane appears frozen.
Expected
Each instance stays responsive when the terminal is (un)focused, as it would if it ran its own engine.
Actual
- Every attached TUI stops responding at the same time.
opencode service statusstill prints the URL while the clients look stuck; restarting the service clears it.- Observed 10 concurrent
opencodeclient processes all attached to a singleopencode serve --service(PID 91857).
Diagnostics from the reporting machine
- One shared service, many clients.
psshows a singleopencode serve --serviceand 10opencodeclients parented by differentzshprocesses; some had been alive for ~2 days. - Bloated database.
~/.local/share/opencode/opencode.dbis 360 MB with roughly 60% free pages (freelist_count55,002 ofpage_count92,226 ≈ 200 MB reclaimable byVACUUM). Table data:session_message92 MB,part41 MB,message10 MB,kv6 MB. - Continuous snapshot churn.
~/.local/share/opencode/log/opencode.logcontains 2,366spawning process … snapshot/… diff-files|ls-filesentries, plus recurringprovider.updated/model.updatedevents across every location. - Stale clients. Four long-lived clients are still on 2.0.27 (
update check current=2.0.27 latest=2.0.29), i.e. several instances were never restarted after an upgrade.
Hypothesis
Because v2 routes every TUI through one background service, any per-request stall in that service (SQLite write-lock contention on the large, mostly-free database, or a busy event loop) blocks all clients at once. Switching terminal tabs does not cause the stall; it makes an already-stuck service visible. opencode --standalone runs a private server per TUI and should not show this — worth adding to triage.
Not a duplicate (as far as I can tell)
- service: 100% CPU hang when snapshotting a very large git worktree #50734 is a 100% CPU hang while snapshotting a very large worktree (1.4M files) on Linux/WSL. Here the worktree is normal sized —
git ls-files --others --exclude-standardreturns 1 file (node_modules is gitignored). - opencode -c/-i TUI sessions hang permanently: zombie git child under project-copy-refresh snapshot step #40439 / WSL2: server event-loop deadlock (zombie git children) when Desktop app bootstraps multiple instances concurrently; drvfs project amplifies #36840 are zombie-git-child / multi-instance bootstrap deadlocks (closed).
- OpenCode background service hangs Terminal.app #51329 is Terminal.app refusing to quit due to the leaked service process — different symptom.
Requests
- Make the shared service resilient to one slow client/request: per-request timeouts and backpressure so a stalled session cannot freeze every attached TUI.
- Investigate SQLite write-lock contention with many concurrent clients, and reclaim/report the free-page bloat.
- Document (or bound) how many TUIs should share one service; consider surfacing a "service busy" state instead of a silent freeze.
Activity
opencode-agent commentedon Oct 14, 2026
Thanks for the detailed diagnostics! As you say, switching tabs only reveals the freeze; it doesn't cause it. To reproduce this we need to know what the shared service is doing while the clients are stuck. Next time it happens, could you check:
opencode serve --serviceprocess during the freeze (top -pid <pid>or Activity Monitor). Is it near 100% or idle?curl -m 5 <url from opencode service status>. Does it respond, and how fast?~/.local/share/opencode/log/opencode.log(the minute or two before and during it), especially anyEvent stream stalledorBackground service is unresponsivelines.opencode --standaloneavoid it under the same workflow?A short description in your own words of what you were doing when it froze would also help.
You can reply here or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know you're done.
These existing issues are closely related (ordered by likelihood). Please check whether one of them already covers your problem:
Event stream stalled)eventtable: opencode.db reaches 13GB+, mostlymessage.updated.1snapshots (no retention/compaction) #33356:opencode.dbgrowth and reclaiming free spaceshivamtiwari3 commentedon Oct 14, 2026
Correcting my own report after checking current
dev:The snapshot cross-process index race I hypothesized is already handled upstream. Snapshot moved to
packages/core/src/snapshot.ts, and the Git service now uses a per-process temporary index (withTemporaryIndex— "Processes never contend onindex.lock") plus a cross-processopencode-pack.lockfor packing. So that is not the cause.What still stands from my diagnostics: a single OpenCode workspace had 10 TUI instances, a single background service, and a 368 MB SQLite DB that was ~60% free pages (VACUUM shrank it to 146 MB). Please treat this as a symptom report — several instances in VS Code terminal tabs freezing together on tab switch. Happy to collect more data (service logs, a repro) on request.
opencode-agent commentedon Oct 14, 2026
Thanks for the correction, and for checking the snapshot code on
dev. Treating this as a symptom report works for us.Since you offered to collect data: we still can't reproduce this, because we don't know what the shared service is doing while the TUIs are frozen. Next time it happens, before you restart the service, could you share:
opencode serve --serviceprocess (top -pid <pid>or Activity Monitor). Is it near 100% or idle?curl -m 5 <url from opencode service status>. Does it respond, and how fast?~/.local/share/opencode/log/opencode.log, especially anyEvent stream stalledorBackground service is unresponsivelines.opencode --standaloneavoid it with the same workflow?You shrank the database with
VACUUM, so it's also worth noting whether the freezes still happen afterwards (with every client on 2.0.29). If they stop, that points to the database. If they continue, it points somewhere else, closer to #54181 or #52049.opencode-agent commentedon Oct 17, 2026
We're closing this for now because we haven't received the diagnostics we'd need to reproduce it. That's what the service was doing during a freeze: its CPU use, whether the service URL still answered, the log lines from around the freeze, and whether
--standaloneor theVACUUMmade a difference.If it happens again, please reply with those details and we can reopen it. Or follow the closely related reports in the meantime: #54181 (the service stops answering on macOS) and #52049 (
Event stream stalledmakes the client replace the service). Thanks for the thorough initial investigation!