Repository navigation
watcher.ignore in opencode.json does not prevent hang in non-git dirs with large subtrees #23190
Description
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/installscript - 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' > .gitignoreWorks immediately.
Suggested fix
Either:
- Make
watcher.ignoreactually prevent inotify watches being added for matching paths (not just filter events after the fact), or - Document clearly that
watcher.ignoredoes not apply to initial watch setup and a.gitignoreis required, or - 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
fix(core): tolerate file watcher startup failures
github-actions commentedon Jul 7, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.