Skip to content

Snapshot system leaks tmp_pack_* files indefinitely, filling disk at ~9.5 GB/hour #14811

Closed

Description

@ChrisMares

Description

The OpenCode snapshot system creates tmp_pack_* files in the git object store under ~/.local/share/opencode/snapshot//objects/pack/ and never cleans them up. These files accumulate at approximately one new ~9.5 GB file per hour while OpenCode is running, and persist after OpenCode exits. This will silently fill any disk to 100% capacity over time.

Environment

  • OS: Ubuntu 24.04, Linux
  • Install method: install script

Plugins

No response

OpenCode version

1.2.10

Steps to reproduce

  1. Run OpenCode in any project
  2. Leave it running for several hours
  3. Check ~/.local/share/opencode/snapshot//objects/pack/

Screenshot and/or share link

No response

Operating System

Ubuntu 24.04

Terminal

wezterm

Activity

  1. github-actions commented on Feb 23, 2026

    @github-actions
    Contributor

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

    These issues describe the same tmp_pack file accumulation problem in the snapshot system. Please review them and consider adding your findings there instead, or confirm if your issue represents a distinct case.

  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    perfIndicates a performance issue or need for optimization
    on Feb 23, 2026
  3. amansingh107 commented on Feb 23, 2026

    @amansingh107

    I think i know why this is happening
    1.Failed Snapshots: Every time you interact with the AI, OpenCode tries to snapshot your workspace. If your project is large (or if you accidentally run it in your home directory), these operations can hang.

    2.Orphaned Files: When the process hangs or is killed, it leaves those tmp_pack_... files in your .local/share/opencode/.../objects/pack folder.

    3.No Auto-Cleanup: The current version of OpenCode (as of early 2026) doesn't have a built-in mechanism to delete these temporary files automatically once they've failed.

  4. Bewinxed commented on Mar 4, 2026

    @Bewinxed

    Hit this on v1.2.16 — 533GB consumed on a 1.1TB disk (filled to 100%).

    Breakdown of the snapshot dir before cleanup:

    • Project snapshot (0e0047...): 270GB total — three abandoned tmp_pack_* files (125G + 72G + 72G) plus a corrupted 749M pack file
    • global snapshot: 264GB total — one 58G tmp_pack_* file plus ~206GB of loose objects across 258 hash directories (averaging 1.3GB each)
    • 5 other snapshots: ~92MB combined (normal)

    The loose object accumulation in global seems like a separate-but-related issue — write-tree creates tree objects that stay reachable from the index, so git gc --prune=7.days can't actually prune them. On top of that, when gc does try to repack, it fails (likely OOM or disk pressure) and leaves the tmp_pack_* files behind, compounding the problem.

    WSL2 Ubuntu, git 2.43.0. Fix was rm -rf ~/.local/share/opencode/snapshot/* — freed 533GB instantly.

  5. rothnic commented on Mar 9, 2026

    @rothnic

    I just found this issue after hitting 100% disk usage, causing opencode to crash. Found the same snapshot folder taking up 163GB of space for me. What is the solution to handling this safely for now? Between this and the memory leak issues, I'm struggling to use opencode for any length of time without running into performance issues.

    I had 120GB if tmp_* files. There are a bunch of pak files that i'm not sure what they are for and the downside of removing them. Most are ~40MB or less, but one is 40GB. Removing the tmp files at least cleaned things up for a bit.

  6. Git-on-my-level commented on Mar 18, 2026

    @Git-on-my-level

    Confirming this on macOS with a local reproduction and concrete cleanup numbers.

    Environment

    • OS: macOS
    • State dir: ~/.local/share/opencode

    What I found locally

    • ~/.local/share/opencode had grown to 45G
    • snapshot/ was 40G
    • one snapshot dir dominated all usage:
      • ~/.local/share/opencode/snapshot/01adec10548001d548c6d7c392e733d8e7535c65 = 40G
    • inside that snapshot:
      • objects/pack/ = 39G
    • of that, tmp_pack_* files alone accounted for about 19.4 GiB

    Examples from that directory:

    • tmp_pack_MzfB9A = 15G
    • tmp_pack_HzAeAw = 2.9G
    • tmp_pack_LAQ6cW = 912M

    Important detail

    • these files were not open by any process when I inspected the snapshot dir itself
    • deleting only the tmp_pack_* files reclaimed about 19-20 GiB immediately
    • the containing snapshot dropped from 40G to 20G
    • free space on the data volume jumped from about 8.5 GiB to 28 GiB

    This strongly suggests abandoned/incomplete git repack artifacts are being left behind without cleanup/rollback/GC.

    I also had stale leaked .opencode serve processes from a separate test issue keeping opencode.db open, but those do not explain the tmp_pack_* accumulation itself.

  7. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    This should be partially addressed by commit 0a80ef4 which adds a 2MB file size limit for snapshotting. Large files are now excluded from snapshots, reducing tmp_pack accumulation from large files.

  8. arthurjd commented on Aug 29, 2026

    @arthurjd

    A fix for this is now available in PR #46037: it prunes stale tmp_pack_* files after every snapshot gc run (success or failure) and rebuilds the snapshot store when gc fails on missing objects (the deterministic unable to read mode when the project's own gc prunes shared objects). Details and a reproducer in #46034.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)perfIndicates a performance issue or need for optimization

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions