Skip to content

fix(opencode): load .gitignore patterns in experimental file watcher#20980

Open
NishantGoswami-Mahakalp wants to merge 1 commit intoanomalyco:devfrom
NishantGoswami-Mahakalp:fix/filewatcher-gitignore
Open

fix(opencode): load .gitignore patterns in experimental file watcher#20980
NishantGoswami-Mahakalp wants to merge 1 commit intoanomalyco:devfrom
NishantGoswami-Mahakalp:fix/filewatcher-gitignore

Conversation

@NishantGoswami-Mahakalp
Copy link
Copy Markdown

@NishantGoswami-Mahakalp NishantGoswami-Mahakalp commented Apr 4, 2026

Issue for this PR

Closes #20977

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The experimental file watcher passes only hardcoded ignore patterns (node_modules, dist, .git, etc.) to @parcel/watcher. It never reads .gitignore or .ignore. So on projects with large gitignored directories (Rust target/, data dirs, build artifacts), Parcel watcher traverses and sets up inotify watches on every single ignored file. This pegs the sidecar at 100% CPU indefinitely on startup.

The fix reads .gitignore and .ignore from the project root before calling w.subscribe() and passes the parsed patterns alongside the existing hardcoded and config-based ignores. This lets Parcel watcher skip ignored subtrees entirely during its initial traversal.

I skipped negation patterns (!) since Parcel watcher's ignore option doesn't support them — they'd need filtering at the callback level instead, which is a separate concern.

How did you verify your code works?

Reproduced the issue on a project with ~11GB of gitignored content (.swarm/, engine/, target/). Without the fix, sidecar stays at 98%+ CPU for 45+ seconds and never settles. With the fix (verified via watcher.ignore config which exercises the same code path), sidecar drops to ~13% on startup and settles to idle within seconds.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Apr 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 4, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

The experimental file watcher (OPENCODE_EXPERIMENTAL_FILEWATCHER) only
used hardcoded ignore patterns, causing it to traverse and watch all
gitignored files. On projects with large ignored directories (build
artifacts, data files), this pegged the sidecar at 100% CPU indefinitely.

Parse .gitignore and .ignore at subscription time and pass the patterns
to Parcel watcher so ignored subtrees are skipped entirely.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Electron desktop app hangs on startup with large .gitignored projects

1 participant