Skip to content

[Bug] Watcher bypasses directory exclusions, causing I/O bottleneck during package installations #3

Description

@Gopesh111

Hi @userhimanshuverma ,
While reviewing the auto-update architecture across parser.py and watcher.py, I noticed a critical edge case. In parser.py, we use exclude_dirs to skip directories like venv/ and node_modules/. However, GraphFileHandler in watcher.py only checks if not event.src_path.endswith('.py') and misses the directory exclusion logic completely.

Steps to Reproduce & Impact

  1. Run the Graph Watcher in the background.
  2. A user or an AI agent runs pip install pandas (or any large package) in their local .venv.
  3. watchdog detects thousands of new .py files being created in the virtual environment.
  4. For every single file, on_created fires, calling update_graph() and executing save_graph() synchronously.
  5. Rewriting the entire JSON graph to disk thousands of times causes a severe I/O bottleneck, freezing the MCP server.

Proposed Solution

Share the exclude_dirs logic between PythonParser and GraphFileHandler so the watcher explicitly ignores events from venv, .git, etc.

I’d be happy to raise a PR to implement this exclusion filtering if you think it's a priority. Let me know!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions