Skip to content

watcher.ignore in opencode.json does not prevent hang in non-git dirs with large subtrees #23190

Closed as not planned

Description

@fgfmds

Description

OpenCode hangs silently — both TUI and opencode run CLI — when launched from a non-git directory that contains a large subtree (e.g. ML dataset, millions of files). The documented watcher.ignore config option does not prevent the hang. Only an actual .gitignore inside a real .git repo avoids it.

Reproduction

Fresh directory with a large data subtree, no git repo:

mkdir /tmp/oc-repro && cd /tmp/oc-repro
# (populate /tmp/oc-repro/data/ with a lot of files, e.g. an ML dataset —
# in my case ~millions of files in data/ under /media/ffarhat/data01/drafter-test)

~/.config/opencode/opencode.json has:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "ollama/qwen2.5-coder:7b",
  "snapshot": false,
  "watcher": {
    "ignore": [
      "node_modules/**",
      ".git/**",
      "data/**",
      "datasets/**",
      "logs/**"
    ]
  },
  "provider": { "...": "..." }
}

Then:

cd /tmp/oc-repro
opencode run -m ollama/qwen2.5-coder:7b "Reply: OK"

Expected: OK within a few seconds (as happens in any clean dir).

Actual: Hangs after printing > build · qwen2.5-coder:7b. No response, no error, no timeout on opencode's side — times out on mine.

State matrix

.git? .gitignore with data/? opencode.json.watcher.ignore with data/**? Result
yes yes yes ✓ works (returns response quickly)
yes no yes ✗ hangs
no no yes ✗ hangs
no yes (file present without .git) yes ✗ hangs (not tested in this matrix but implied)

Only the .git + .gitignore combination fixes it. watcher.ignore in opencode.json appears non-functional for this purpose, or only filters events after enumeration.

Debug log from the hanging case

INFO  ... service=file.watcher directory=/media/ffarhat/data01/drafter-test init
INFO  ... service=file.watcher directory=/media/ffarhat/data01/drafter-test platform=linux backend=inotify watcher backend
INFO  ... service=provider providerID=ollama found
INFO  ... service=session.prompt status=started resolveTools
INFO  ... service=tool.registry status=completed duration=0 bash
[stops here — no further output for 30+ seconds]

Log stops mid-tool-registration, implying the watcher setup (inotify recursion?) is blocking the event loop. data/ in that tree has millions of files; inotify would need a watch per directory.

Environment

  • OpenCode 1.4.10 (also reproduced on 1.4.7)
  • Ubuntu 24.04.4 LTS, kernel 6.x
  • Installed via official https://opencode.ai/install script
  • Ollama backend, but same behavior with --pure

Workaround

Initialize a git repo in the heavy dir and add a .gitignore:

git init
printf 'data/\nlogs/\n' > .gitignore

Works immediately.

Suggested fix

Either:

  1. Make watcher.ignore actually prevent inotify watches being added for matching paths (not just filter events after the fact), or
  2. Document clearly that watcher.ignore does not apply to initial watch setup and a .gitignore is required, or
  3. Add a hard timeout on initial watcher setup to surface the problem explicitly rather than hanging indefinitely.

Happy to test a patched build if helpful.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    perfIndicates a performance issue or need for optimization
    on Apr 17, 2026
  2. removed
    perfIndicates a performance issue or need for optimization
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  3. github-actions commented on Jul 7, 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