Skip to content

TUI hangs silently at startup when inotify instances are exhausted (still in 2.3.0, no .git needed) #64149

Closed as duplicate

Description

@shiqimei

Description

OpenCode 2.3.0 still hangs at startup with a blank screen when the user's inotify instances are exhausted (fs.inotify.max_user_instances). This is the same failure as #16610, which was closed automatically for inactivity rather than fixed. Two details differ from that report:

  • It happens without any .git directory: the working directory was an empty folder.
  • The hang is at the very first watcher, on the global config directory. The server logs watcher subscribe path=~/.config/opencode type=directory and nothing after it. It never logs watcher started or location services booted, and the TUI never draws. Both processes sit idle in futex/epoll waits indefinitely.

When one instance is free, startup works, and the later fs.watch calls fail fast with EMFILE: too many open files, watch '/etc' (logged as failed to watch directory) without blocking. So only the config-directory watcher blocks on exhaustion. That suggests the inotify backend of @parcel/watcher is waiting on a subscription that can never complete.

Steps to reproduce

  1. Exhaust inotify instances for the current user, e.g. temporarily sudo sysctl -w fs.inotify.max_user_instances=<current usage>, or run a process that calls inotify_init() until it gets EMFILE and keeps the descriptors open.
  2. In an empty directory (no .git), run opencode --print-logs --log-level debug.
  3. Observe the blank screen. The last server log line is the watcher subscribe for ~/.config/opencode.
  4. Release one instance and run again: OpenCode starts normally.

Same result with --standalone.

Expected behavior

Start without the file watcher (with a warning), or exit with a clear error that names the inotify limit, rather than hanging silently.

How we hit it

On a headless Linux machine, a long-running process kept spawning dbus-launch. Each leftover dbus-daemon --session held an inotify instance until the default limit of 128 was reached. Any slow leak of inotify instances can trigger this, which makes the silent hang hard to diagnose.

OpenCode version

2.3.0

Operating System

Linux (x86_64, kernel 6.12), headless, max_user_instances=128

Terminal

Any (also reproduced under script(1) with no terminal attached)

Activity

  1. opencodejr commented on Nov 16, 2026

    @opencodejr
    Contributor

    Thanks for the clear report and the reproduction steps.

    I think this is a duplicate of #62687. That issue was reproduced with the same method you used: max_user_instances lowered and a second process holding every inotify instance. The server then got stuck inside the native @parcel/watcher subscribe call, and it still happened on the latest dev. Your log stops after watcher subscribe and never reaches watcher started, which fits the same stuck call. In your case it happens during TUI startup, on the first watcher.

    Possible duplicates and related issues, ordered from most to least likely:

    Workaround: start OpenCode with the file watcher turned off, as #62687 confirmed:

    OPENCODE_DISABLE_FILEWATCHER=1 opencode

    The newer name OPENCODE_FILEWATCHER_DISABLE works too.

    I'm closing this issue now as a duplicate of #62687. Please add your details there, especially that it hangs on the first (config directory) watcher with no .git present and still happens on 2.3.0. If you think this is a different problem, reply here and the issue will reopen.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions