Skip to content

Bug: opencode killing SSD by generating .so Files in /tmp #42880

Closed as not planned

Description

@weboliver

Description

opencode is generating .so Files in a tremendous velocity, while working.

the Bug is old so I just submit my workaround:

Create a Ram Disk for Folder /tmp:

sudo nano /etc/fstab
tmpfs /tmp tmpfs rw,nosuid,nodev,size=4G,mode=1777 0 0
sudo mount -a

Then add a timerjob that removes the generated .so files:

~/.local/bin/tmp-opencode-cleanup.sh

#!/usr/bin/env bash
find /tmp -maxdepth 1 -regextype posix-extended
-regex '/tmp/.?[0-9a-f]+-[0-9]{8}.so'
-mmin +1 -delete

~/.config/systemd/user/tmp-opencode-cleanup.timer

[Timer]
OnBootSec=1min
OnUnitActiveSec=1min
Persistent=true

sudo systemctl --user enable --now tmp-opencode-cleanup.timer

rate approx: ~100 - 700 MB/Minute when working / depends on answer rate

Would be really helpful, when this bug could be corrected :)

Thank you,
Oliver

Plugins

GSD-core

OpenCode version

1.18.18

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

Ubuntu 22.04 / WSL2

Terminal

No response

Activity

  1. github-actions commented on Aug 16, 2026

    @github-actions
    Contributor

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

    Please check whether any of the above already covers your report, and consider adding your findings (rate ~700 MB/min, the RAM disk + cleanup timer workaround) as a comment on the most relevant existing issue rather than opening a new one. If your case is distinct, please let a maintainer know.

  2. weboliver commented on Aug 16, 2026

    @weboliver
    Author

    Traced this: opencode itself creates these files (main PID, not a subprocess), one per LLM output event, and never cleans them up.

    strace -f -e trace=openat,unlink,unlinkat -P /tmp -p <opencode_pid> on v1.18.18 during a normal chat session shows:

    • Every .so write comes from a fresh PID/TID that resolves back to opencode itself — a new one per LLM output chunk (1:1 timing correlation), never reused.
    • unlink/unlinkat traced in parallel but produced ~0 matching events for these paths:
      grep -c 'openat..so' trace.log # N opens
      grep -c 'unlink.
      .so' trace.log # ~0
    • → real leak, not fast cache churn. Matches the reported ~700 MB/min.

    Env: WSL2, /tmp on tmpfs.

    sudo strace -f -e trace=openat,unlink,unlinkat -e signal=none -P /tmp -tt -p 2>&1 | grep --line-buffered '.so'
    [pid 245737] 21:07:56.991061 openat(13, ".9adf5ebbf3f2ffdf-00000000.so", O_WRONLY|O_CREAT|O_CLOEXEC, 0644) = 14
    [pid 245760] 21:07:59.375999 openat(13, ".9adf5ebde3fcefd7-00000000.so", O_WRONLY|O_CREAT|O_CLOEXEC, 0644) = 14
    [pid 245867] 21:08:12.598743 openat(13, ".9adf5ebff7ffef97-00000000.so", O_WRONLY|O_CREAT|O_CLOEXEC, 0644) = 14
    [pid 245893] 21:08:15.515089 openat(13, ".9adf5ebfe3efefd7-00000000.so", O_WRONLY|O_CREAT|O_CLOEXEC, 0644) = 14
    [pid 245992] 21:08:32.394968 openat(13, ".9adf5ebbf3f0ff87-00000000.so", O_WRONLY|O_CREAT|O_CLOEXEC, 0644) = 14
    [pid 246032] 21:08:35.498223 openat(13, ".9adf5ebdeae0fdb7-00000000.so", O_WRONLY|O_CREAT|O_CLOEXEC, 0644) = 14
    [pid 246053] 21:08:38.566210 openat(13, ".9adf5ebde3e3fdff-00000000.so", O_WRONLY|O_CREAT|O_CLOEXEC, 0644) = 14
    [pid 246176] 21:08:57.710706 openat(13, ".9adf5ef9f6e0ffd7-00000000.so", O_WRONLY|O_CREAT|O_CLOEXEC, 0644) = 14
    [pid 246234] 21:09:00.636154 openat(13, ".9adf5efbe7fafdb7-00000000.so", O_WRONLY|O_CREAT|O_CLOEXEC, 0644) = 14
    [pid 246263] 21:09:04.482977 openat(13, ".9adf5efbeae9fd97-00000000.so", O_WRONLY|O_CREAT|O_CLOEXEC, 0644) = 14
    [pid 246411] 21:09:15.574247 openat(13, ".9adf5efdfffdfdaf-00000000.so", O_WRONLY|O_CREAT|O_CLOEXEC, 0644) = 14

    I hope that helps.

    Best Regards,
    Oliver

  3. thdxr commented on Aug 19, 2026

    @thdxr
    Member

    Update: the unbounded native-library temp-file growth described here is fixed in OpenCode V2.

    As of V2 build 0.0.0-dev-17643, the compiled CLI uses Bun 1.4.0-canary.1 (681a49bee). That runtime includes oven-sh/bun#29587, which replaces the unique temporary .so/.dylib/.node extraction on every load with a deterministic, content-hashed path reused across calls, Workers, processes, and restarts. The V2 build provenance is workflow run 32216069554.

    This bounds extraction to one reusable file per embedded native module and user instead of allowing unbounded disk growth. It does not mean the temp directory will contain zero native files, and upgrading does not remove files leaked by older builds; those stale randomly named files can be cleaned up after all older OpenCode processes have stopped.

  4. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    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 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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