You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Snapshot mechanism stalls on large workspaces: ~1min per git snapshot, permanent index.lock deadlock after a crash" #42597
On a large git workspace (~5,300 tracked files) running opencode 1.18.18 on Windows, the project snapshot mechanism becomes pathological:
Every agentic iteration triggers a full git add -A + git commit inside a custom snapshot repository. On a large workspace each of these takes ~1 minute (git add -A ≈ 57s, git commit ≈ 19s measured locally), so every single model interaction is blocked for ~1 minute before anything is sent.
When a snapshot git process crashes (or is killed), it leaves a stale index.lock in the snapshot repository. From then on, every snapshot operation fails with fatal: Unable to create '...index.lock': File exists and opencode retries indefinitely — memory balloons to 6–8 GB, disk reads exceed 10 GB, and no response is ever produced. The only fix is to manually delete the index.lock file.
Plugins
No response
OpenCode version
1.18.18
Steps to reproduce
Open a large repo (several thousand tracked files) in opencode on Windows.
Verify the snapshot git repo under ~/.local/share/opencode/snapshot/<projectID>/...:
Run git add -A in that repo → observe tens of seconds.
Run git commit → same.
Trigger a snapshot operation and then kill the opencode process mid-operation → a stale index.lock is left behind.
Restart opencode in the same directory → every interaction now logs:
WARN level=WARN message="failed to add snapshot files" exitCode=128
stderr="fatal: Unable to create '.../snapshot/.../index.lock': File exists.
Another git process seems to be running in this repository..."
The session becomes unresponsive: ~6–8 GB RSS, continually increasing disk reads, and no answer is returned, because snapshot never succeeds and opencode retries forever.
Adding data points from Windows 11 / opencode 1.18.33 (CLI + Desktop) — same snapshot pathology, with three extra findings that made it catastrophic and might help debugging.
Environment: worktree is a Dropbox-synced docs tree with ~1.68M files across many nested git repositories.
1. Two artifacts made every git add fail fatally, so the snapshot index was NEVER persisted — which turns the "~1 min per snapshot" into "full re-scan on every single agent step":
a nested git repository with zero commits (a stray git init that was never committed) → fatal: '<dir>/' does not have a commit checked out
a literal nul file (0 bytes, created by a > nul redirect from Git Bash) at the worktree root → fatal: invalid path 'nul'
Both are invisible in opencode's log — the only symptom was generic slowness. Each failed add meant the next step re-scanned the whole tree again. One of these was created ~2 weeks before we diagnosed the slowness, which matches when symptoms started.
2. The hang variant here is a CPU livelock, not a stdin block. Repeatedly observed a git parent/child pair where the parent sits at 0 CPU while the child spins at ~100% of one core for 5–15 minutes with exactly 0 bytes of I/O (Process IOReadBytes/IOWriteBytes = 0), holding index.lock. A second concurrent snapshot op then blocks at 0 CPU on the same lock. The command line matches the parent/child git add --all --sparse --pathspec-from-file=- --pathspec-file-nul shape from #41648, but with the opposite CPU signature (spin vs. sleep-on-stdin), so the stdin theory may only cover part of the failure space.
3. Agent-facing symptom: "zombie" assistant messages with zero tokens. While the snapshot blocks the loop, the assistant message is created but no process/stream log lines ever appear, and the message is finalized (sometimes only when the instance closes) with tokens.output = 0 and no finish reason — no error logged at all. Measured instances: one turn hung for 1442s (24 min) and another for 391s producing nothing. From the user's perspective this looks exactly like a provider outage.
Fix that worked here (after removing the two fatal artifacts): added the heavy subtrees to the worktree .gitignore (1.68M → 125k files), ran one clean git add directly in the snapshot repo to persist the index (3.7 MB), after which snapshot adds became incremental and fast (2.2s, 0 errors).
Suggestions: (a) surface snapshot git add fatals in the log/UI instead of silently retrying full rescans forever, (b) skip embedded repos without commits the same way gitignored files are handled, (c) don't let the snapshot git add block the agent loop (async or bounded timeout).
Related: #41648 (stdin-block variant, macOS), #29413 (orphaned index.lock on Windows).
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.
Activity
fifaliao commentedon Aug 14, 2026
Set in the project
opencode.json:{ "snapshot": false }and delete any stale
index.lockin the snapshot repo:This restores normal interactivity but disables undo/redo for file changes.
github-actions commentedon Aug 14, 2026
This issue might be a duplicate of existing issues. Please check:
git add --sparse --pathspec-from-file=-hangs indefinitely blocked on stdin (not a zombie — process stays alive inSsstate) #41648: Desktop snapshot'sgit add --sparse --pathspec-from-file=-hangs indefinitely — related snapshot hang issueCENFARG commentedon Sep 30, 2026
Adding data points from Windows 11 / opencode 1.18.33 (CLI + Desktop) — same snapshot pathology, with three extra findings that made it catastrophic and might help debugging.
Environment: worktree is a Dropbox-synced docs tree with ~1.68M files across many nested git repositories.
1. Two artifacts made every
git addfail fatally, so the snapshot index was NEVER persisted — which turns the "~1 min per snapshot" into "full re-scan on every single agent step":git initthat was never committed) →fatal: '<dir>/' does not have a commit checked outnulfile (0 bytes, created by a> nulredirect from Git Bash) at the worktree root →fatal: invalid path 'nul'Both are invisible in opencode's log — the only symptom was generic slowness. Each failed add meant the next step re-scanned the whole tree again. One of these was created ~2 weeks before we diagnosed the slowness, which matches when symptoms started.
2. The hang variant here is a CPU livelock, not a stdin block. Repeatedly observed a git parent/child pair where the parent sits at 0 CPU while the child spins at ~100% of one core for 5–15 minutes with exactly 0 bytes of I/O (Process IOReadBytes/IOWriteBytes = 0), holding
index.lock. A second concurrent snapshot op then blocks at 0 CPU on the same lock. The command line matches the parent/childgit add --all --sparse --pathspec-from-file=- --pathspec-file-nulshape from #41648, but with the opposite CPU signature (spin vs. sleep-on-stdin), so the stdin theory may only cover part of the failure space.3. Agent-facing symptom: "zombie" assistant messages with zero tokens. While the snapshot blocks the loop, the assistant message is created but no
process/streamlog lines ever appear, and the message is finalized (sometimes only when the instance closes) withtokens.output = 0and no finish reason — no error logged at all. Measured instances: one turn hung for 1442s (24 min) and another for 391s producing nothing. From the user's perspective this looks exactly like a provider outage.Fix that worked here (after removing the two fatal artifacts): added the heavy subtrees to the worktree
.gitignore(1.68M → 125k files), ran one cleangit adddirectly in the snapshot repo to persist the index (3.7 MB), after which snapshot adds became incremental and fast (2.2s, 0 errors).Suggestions: (a) surface snapshot
git addfatals in the log/UI instead of silently retrying full rescans forever, (b) skip embedded repos without commits the same way gitignored files are handled, (c) don't let the snapshotgit addblock the agent loop (async or bounded timeout).Related: #41648 (stdin-block variant, macOS), #29413 (orphaned index.lock on Windows).
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊