Repository navigation
Orphaned index.lock in snapshot gitdir causes blocking snapshot queue on Windows (Git Bash / mintty) #29413
Description
Description
When OpenCode is terminated ungracefully (for example: closing mintty, Ctrl+C during execution, or abrupt terminal shutdown), the internal snapshot repository under:
~/.local/share/opencode/snapshot///
can be left with a stale/orphaned index.lock file.
On subsequent runs, snapshot operations such as git add --sparse block waiting for the git lock timeout (~12–15s per attempt on Windows/git). Since snapshot operations appear to be serialized through a per-gitdir semaphore/mutex, the entire snapshot pipeline becomes blocked.
This causes OpenCode to appear frozen or extremely slow:
prompt submitted
model header appears
no response for long periods
high CPU/disk activity
no visible error message
The issue is especially reproducible on Windows + Git Bash (mintty), likely because abrupt terminal shutdowns can interrupt git operations without cleanup.
Important:
GitHub Copilot authentication works correctly
API requests work correctly outside OpenCode (verified with curl + streaming)
Running in smaller repositories improves responsiveness
Running from HOME directories worsens the issue significantly
Observed code behavior
The git runner appears to swallow git failures silently:
B.catch((R) => B.succeed({ code: ExitCode(1), text: "", stderr: ... }))
This makes the failure invisible to the user and difficult to diagnose.
Steps to reproduce
Run OpenCode from Git Bash (mintty) on Windows
Interrupt execution abruptly:
close mintty window
or Ctrl+C during snapshot activity
Run:
opencode run "hello"
Observe long hangs/blocking behavior
Expected behavior
OpenCode should:
detect stale/orphaned index.lock files
automatically clean old locks
or at minimum surface a clear snapshot/git error
Actual behavior
OpenCode becomes extremely slow or appears frozen until the lock is manually removed.
Current workaround
find ~/.local/share/opencode/snapshot -name "index.lock" -delete
Suggested fix
Before snapshot git operations (git add, git write-tree, etc.), detect stale locks:
const lockPath = path.join(gitdir, "index.lock");
if (await fs.exists(lockPath)) {
const stat = await fs.stat(lockPath);
if (Date.now() - stat.mtimeMs > 30_000) {
await fs.rm(lockPath);
}
}
Plugins
No response
OpenCode version
Version: 1.15.10 (Windows x64)
Steps to reproduce
No response
Screenshot and/or share link
When OpenCode is terminated ungracefully (for example: closing mintty, Ctrl+C during execution, or abrupt terminal shutdown), the internal snapshot repository under:
~/.local/share/opencode/snapshot///
can be left with a stale/orphaned index.lock file.
On subsequent runs, snapshot operations such as git add --sparse block waiting for the git lock timeout (~12–15s per attempt on Windows/git). Since snapshot operations appear to be serialized through a per-gitdir semaphore/mutex, the entire snapshot pipeline becomes blocked.
This causes OpenCode to appear frozen or extremely slow:
prompt submitted
model header appears
no response for long periods
high CPU/disk activity
no visible error message
The issue is especially reproducible on Windows + Git Bash (mintty), likely because abrupt terminal shutdowns can interrupt git operations without cleanup.
Important:
GitHub Copilot authentication works correctly
API requests work correctly outside OpenCode (verified with curl + streaming)
Running in smaller repositories improves responsiveness
Running from HOME directories worsens the issue significantly
Observed code behavior
The git runner appears to swallow git failures silently:
B.catch((R) => B.succeed({ code: ExitCode(1), text: "", stderr: ... }))
This makes the failure invisible to the user and difficult to diagnose.
Steps to reproduce
Run OpenCode from Git Bash (mintty) on Windows
Interrupt execution abruptly:
close mintty window
or Ctrl+C during snapshot activity
Run:
opencode run "hello"
Observe long hangs/blocking behavior
Expected behavior
OpenCode should:
detect stale/orphaned index.lock files
automatically clean old locks
or at minimum surface a clear snapshot/git error
Actual behavior
OpenCode becomes extremely slow or appears frozen until the lock is manually removed.
Current workaround
find ~/.local/share/opencode/snapshot -name "index.lock" -delete
Suggested fix
Before snapshot git operations (git add, git write-tree, etc.), detect stale locks:
const lockPath = path.join(gitdir, "index.lock");
if (await fs.exists(lockPath)) {
const stat = await fs.stat(lockPath);
if (Date.now() - stat.mtimeMs > 30_000) {
await fs.rm(lockPath);
}
}
Operating System
Windows 11 Git Bash (mintty) GitHub Copilot provider
Terminal
Git Bash (mintty terminal) running on Windows 11
Activity
github-actions commentedon May 26, 2026
This issue might be a duplicate of existing issues. Please check:
index.lockin snapshot gitdir blocks LLM responses after crash (Windows, same suggested fixes)index.lockbreaks Modified Files and undo for a workspaceIf your issue is distinct from these, please clarify what's different. Otherwise, adding a reaction or comment on the existing issues helps maintainers prioritize the fix.
liaosf commentedon Jun 20, 2026
Same issue on Windows 11 (PowerShell 7).
Environment:
Measured startup timeline from fresh log:
\
00:00:18 instance created → config loaded → LSP ready
00:00:21 MCP tools init complete
00:00:27 project copy refresh started ← git snapshot
00:00:37 first message processing ← 10s delay
00:00:44 first LLM streaming response ← another 7s subagent init
\\
Result: 27 seconds from terminal launch to first LLM output, for a minimal 20-file repo.
Also affected by #27688 (snapshot cwd mismatch in git subdirectory), which adds repeated pathspec errors that compound the delay.
Both issues together make the first interaction on Windows practically unusable (expect 20-30s wait before any response).
github-actions commentedon Aug 19, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.