fix(opencode): load .gitignore patterns in experimental file watcher#20980
Open
NishantGoswami-Mahakalp wants to merge 1 commit intoanomalyco:devfrom
Open
fix(opencode): load .gitignore patterns in experimental file watcher#20980NishantGoswami-Mahakalp wants to merge 1 commit intoanomalyco:devfrom
NishantGoswami-Mahakalp wants to merge 1 commit intoanomalyco:devfrom
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
53dad6a to
e572a41
Compare
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
e572a41 to
2522d72
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #20977
Type of change
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.gitignoreor.ignore. So on projects with large gitignored directories (Rusttarget/, 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
.gitignoreand.ignorefrom the project root before callingw.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.ignoreconfig which exercises the same code path), sidecar drops to ~13% on startup and settles to idle within seconds.Checklist