Skip to content

EMFILE: too many open files, watch 'home/user/.local/state/opencode/latest/tui' #50566

Closed as duplicate

Description

@juliancalzada

Description

https://github.com/anomalyco/opencode/issues/new?template=bug-report.yml&title=TUI+crash%3A+EMFILE%3A+too+many+open+files%2C+watch+%27%2Fhome%2Fjcal%2F.local%2Fstate%2Fopencode%2Flatest%2Ftui%27&opencode-version=2.0.12&os=Linux+7.2.6-1-cachyos+%28x64%29&terminal=ghostty+1.3.1-arch2.2&reproduce=Reported+automatically+from+the+OpenCode+crash+screen.+If+you+can%2C+describe+what+you+were+doing+when+it+crashed.&description=The+OpenCode+TUI+crashed+with+an+unexpected+error.%0A%0A**Error%3A**+EMFILE%3A+too+many+open+files%2C+watch+%27%2Fhome%2Fjcal%2F.local%2Fstate%2Fopencode%2Flatest%2Ftui%27%0A%0A**Stack+trace%3A**%0A%60%60%60%0AError%3A+EMFILE%3A+too+many+open+files%2C+watch+%27%2Fhome%2Fjcal%2F.local%2Fstate%2Fopencode%2Flatest%2Ftui%27%0A++++at+watch+%28unknown%29%0A++++at+new+FSWatcher+%28internal%3Afs%2Fwatch%3A101%3A31%29%0A++++at+watch+%28internal%3Afs%2Fwatch%3A172%3A23%29%0A++++at+NK+%28%2F%24bunfs%2Froot%2Fchunk-ys6yz61r.js%3A2590%3A6415%29%0A++++at+ZU+%28%2F%24bunfs%2Froot%2Fchunk-ys6yz61r.js%3A2590%3A6580%29%0A++++at+Yo+%28%2F%24bunfs%2Froot%2Fchunk-vchxr2bz.js%3A2%3A8344%29%0A++++at+%3Canonymous%3E+%28%2F%24bunfs%2Froot%2Fchunk-ys6yz61r.js%3A2590%3A3284%29%0A++++at+%3Canonymous%3E+%28%2F%24bunfs%2Froot%2Fchunk-vchxr2bz.js%3A2%3A16044%29%0A++++at+rA+%28%2F%24bunfs%2Froot%2Fchunk-vchxr2bz.js%3A2%3A11377%29%0A++++at+Ge+%28%2F%24bunfs%2Froot%2Fchunk-vchxr2bz.js%3A2%3A11153%29%0A%60%60%60

Plugins

No response

OpenCode version

2.0.12

Steps to reproduce

opencode in the terminal

Screenshot and/or share link

Image

Operating System

Arch Linux Kernel: 7.2.6-1-cachyos x86_64

Terminal

ghostty

Activity

  1. github-actions commented on Sep 22, 2026

    @github-actions
    Contributor

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

  2. changed the title [-]EMFILE: too many open filees, watch 'home/user/.local/state/opencode/latest/tui'[/-] [+]EMFILE: too many open files, watch 'home/user/.local/state/opencode/latest/tui'[/+] on Sep 22, 2026
  3. CGuiho commented on Oct 4, 2026

    @CGuiho

    I've got it today.

  4. gandb commented on Oct 21, 2026

    @gandb

    The same here:

    Error: EMFILE: too many open files, watch '/home/gandb/.config/opencode'
    at watch (unknown)
    at new FSWatcher (internal:fs/watch:101:31)
    at watch (internal:fs/watch:172:23)
    at Dpe (/$bunfs/root/chunk-e5561drs.js:3:55263)
    at Ri (///root/chunk-s6m57scs.js:2:6899)
    at get (///root/chunk-s6m57scs.js:2:17800)
    at children (///root/chunk-pa6pb7e8.js:2590:3713)
    at (///root/chunk-s6m57scs.js:2:14480)
    at je (///root/chunk-s6m57scs.js:2:9876)
    at K (///root/chunk-s6m57scs.js:2:9657)

    Error: EMFILE: too many open files, watch '/home/gandb/.config/opencode'
    Stack trace:
    Error: EMFILE: too many open files, watch '/home/gandb/.config/opencode'
        at watch (unknown)
        at new FSWatcher (internal:fs/watch:101:31)
        at watch (internal:fs/watch:172:23)
        at Dpe (/$bunfs/root/chunk-e5561drs.js:3:55263)
        at Ri (/$bunfs/root/chunk-s6m57scs.js:2:6899)
        at get (/$bunfs/root/chunk-s6m57scs.js:2:17800)
        at children (/$bunfs/root/chunk-pa6pb7e8.js:2590:3713)
        at <anonymous> (/$bunfs/root/chunk-s6m57scs.js:2:14480)
        at je (/$bunfs/root/chunk-s6m57scs.js:2:9876)
        at K (/$bunfs/root/chunk-s6m57scs.js:2:9657)
    Additional context: This error appeared inside the orca app when opencode is triggered from there. The issue occurs specifically when using OpenCode within the orca application environment.
    Environment:
    - OpenCode version: 2.1.2
    - OS: Linux 7.0.0-38-generic (x64)
    - Terminal: Orca 1.4.235
    Reproduction: Is intermitent, but some hours using orca is possible to reproduce.
    
    1. Install orca from https://www.onorca.dev/download  
    2. Use some hours opencode into the IDE
    
    ---
    You can now copy this text and paste it into the GitHub issue form at the URL that was opened in your browser. The form should be pre-filled with the template and title, and you just need to paste the body and submit.
    
    ### Plugins
    
    _No response_
    
    ### OpenCode version
    
    2.1.2
    
    ### Steps to reproduce
    
    Reported automatically from the OpenCode crash screen. If you can, describe what you were doing when it crashed.
    
    ### Screenshot
    
    _No response_
    
    ### Operating System
    
    Linux 7.0.0-38-generic (x64)
    
    ### Terminal
    
    Orca 1.4.235
    
  5. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the report! I think this is a duplicate of #51208. In 2.0.12 the TUI watched its state directory (~/.local/state/opencode/<channel>/tui) with fs.watch and didn't handle errors. So when the system ran out of inotify instances (EMFILE), the whole TUI crashed instead of just turning off live-reload.

    Possible duplicates and related issues, ordered by likelihood:

    As of v2.1.4, all TUI file watchers handle this error: a watch that fails disables live-reload instead of crashing the TUI. Please upgrade to v2.1.4 or later.

    If you hit this before you can upgrade, either of these should help:

    • Raise the inotify limit: sudo sysctl -w fs.inotify.max_user_instances=2048
    • Or, on v2.1.4 or later, turn off file watching with OPENCODE_DISABLE_FILEWATCHER=1

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different, for example if it still happens on v2.1.4 or later.

  6. opencodejr commented on Oct 29, 2026

    @opencodejr
    Contributor

    Closing this as a duplicate of #51208, since we haven't heard back. This crash came from the TUI's fs.watch on ~/.local/state/opencode/<channel>/tui not handling inotify exhaustion (EMFILE). #51210, #51243 and #51536 fixed it: as of v2.1.4, a watch that fails just disables live-reload instead of crashing the TUI. The related ~/.config/opencode variant is tracked in #51489.

    Please upgrade to v2.1.4 or later. If you still see this crash on v2.1.4 or later, comment here with your version and the stack trace and we'll take another look. Thanks for the report!

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions