Skip to content

fix(watcher): ignore nested .git and .codegraph directories to prevent fd leak#517

Open
vyductan wants to merge 1 commit into
colbymchenry:mainfrom
vyductan:fix/watcher-nested-git-leak
Open

fix(watcher): ignore nested .git and .codegraph directories to prevent fd leak#517
vyductan wants to merge 1 commit into
colbymchenry:mainfrom
vyductan:fix/watcher-nested-git-leak

Conversation

@vyductan
Copy link
Copy Markdown

Problem

The file watcher (chokidar) in FileWatcher only ignored .git and .codegraph directories when they were at the root of the workspace. If the workspace contained nested git repositories (e.g., in a monorepo setup or via git subtrees/submodules), the nested .git directories were walked and watched recursively.

In large codebases (such as those containing git subtree caches with 150k+ files), this would cause the node process to open tens of thousands of file descriptors, leading to ENFILE: file table overflow and crashing development servers (like Vite/Rolldown).

Solution

Updated isAlwaysIgnored in src/sync/watcher.ts to split the relative path by / and check if any segment equals .git or .codegraph. This correctly ignores nested metadata folders at any depth.

After applying this fix, the number of open file descriptors on a monorepo with nested .git cache files dropped from 110,000+ to ~100.

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.

1 participant