Skip to content

Snapshot git index.lock blocks LLM responses for 60+ seconds after crash #28952

Closed as not planned

Description

@nicholas110

Symptoms

  • OpenCode appears to "spin" with no response for 60+ seconds
  • All models seem unresponsive (no streaming, no thinking process shown)
  • Eventually a response comes back, but subsequent responses also lag
  • No error messages shown to the user in the UI
  • Only visible in logs: repeated snapshot-related errors with git lock failures

Root Cause

OpenCode's snapshot service uses a local git repository at:

~/.local/share/opencode/snapshot/global/<hash>/

When an OpenCode session crashes unexpectedly (force close, system reboot, process kill), the git repository can be left with a stale index.lock file:

~/.local/share/opencode/snapshot/global/<hash>/.git/index.lock

On the next startup, every snapshot file-change operation tries to acquire the git lock, times out after ~30-40 seconds, and accumulates across multiple snapshot attempts. Since LLM streaming waits on snapshot operations, the total delay before the first token appears can exceed 60 seconds.

Log evidence:

ERROR SnapshotError: Failed to execute git command
Caused by: Unable to create '<path>/.git/index.lock': File exists.

Steps to Reproduce

  1. Start OpenCode and use it normally
  2. Force-kill the OpenCode process (or crash the system)
  3. Restart OpenCode and send a message
  4. Observe 60+ second delay before any response
  5. Check ~/.local/share/opencode/log/ for snapshot-related errors

Workaround

Delete the stale git repository:

rm -rf ~/.local/share/opencode/snapshot/global/*/

OpenCode will recreate it on the next file change.

Or more selectively, just remove the lock file:

rm -f ~/.local/share/opencode/snapshot/global/*/.git/index.lock

Suggested Fix

The snapshot service should:

  1. Detect and automatically clean up stale index.lock files on startup (git lock files older than the process lifetime are always stale)
  2. Or use a short timeout for lock acquisition and fall back gracefully instead of blocking
  3. Or at minimum surface a warning to the user when snapshot operations are blocked

Environment

  • OpenCode version: 1.15.10
  • Platform: Windows 11
  • Client: CLI (opencode)

Activity

  1. github-actions commented on May 23, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of an existing issue. Please check:

    If your issue is distinct (e.g. the LLM response delay aspect isn't covered there), please clarify the difference so maintainers can decide whether to consolidate.

  2. github-actions commented on Jul 23, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions