fix: prevent file descriptor leak from Python venv directories in skills#8869
fix: prevent file descriptor leak from Python venv directories in skills#8869jverkoey wants to merge 4 commits intoopenclaw:mainfrom
Conversation
The chokidar file watcher was monitoring all files in skills directories, including venv, .venv, __pycache__, and site-packages. This caused file descriptors to be held open for thousands of Python package files. Add these directories to DEFAULT_SKILLS_WATCH_IGNORED to prevent the watcher from monitoring them. This complements the pi-coding-agent patch which prevents the loader from scanning into these directories. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
466866d to
e068022
Compare
|
Claude has reviewed this PR following https://raw.githubusercontent.com/openclaw/openclaw/refs/heads/main/docs/help/submitting-a-pr.md. |
|
Adding some more info to this issue. I ran into the issue after installing the transcribe skill (audio to text) with a local model which does indeed setup a Python ".venv" in the skills directory. Confirming that adding ".venv" to the DEFAULT_SKILLS_WATCH_IGNORED fixed the issue. |
bfc1ccb to
f92900f
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing as AI-assisted stale-fix triage. Linked issue #2532 ("[Bug]: If the underlying bug is still reproducible on current main, please reopen this PR (or open a new focused fix PR) and reference both #2532 and #8869 for fast re-triage. |
Summary
Fixes a critical file descriptor leak that occurs when skills contain Python virtual environments. The gateway was accumulating 36,000+ file descriptors and eventually failing with `spawn EBADF` errors.
Fixes #8721 (comment)
Fixes #2532
Fixes #9481
Root Cause
The chokidar file watcher in `src/agents/skills/refresh.ts` monitors all skills directories for changes, but was not ignoring Python virtual environment directories (`venv/`, `.venv/`, `pycache/`, `site-packages/`). Chokidar keeps file descriptors open for all monitored files, causing massive FD accumulation when skills contain Python packages.
Changes
1. Chokidar watcher fix (critical)
Pattern Details
The fix adds these regex patterns to ignore:
Testing
Before fix:
After fix:
Validation Results
Submission Checklist
Implementation Notes
The fix is minimal and non-breaking:
🤖 Generated with Claude Code
Model usage: Haiku 4.5 (analysis and validation)
Effort level: Low (straightforward, focused fix)