[BUG] Runaway file descriptor leak in Claude (v2.1.117) on large monorepo

Resolved 💬 9 comments Opened Apr 22, 2026 by nedimonvam Closed Apr 24, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Claude (v2.1.117) in code/cowork mode causes a runaway increase in open file descriptors when run in a large monorepo. The number of open files grows rapidly (tens of thousands within seconds) and does not stabilize, eventually reaching ~130,000 and exhausting system limits.

The behavior is independent of the user task (even trivial prompts trigger it) and suggests a file descriptor leak and/or uncontrolled file traversal loop. This leads to system-wide instability and crashes.

What Should Happen?

Claude should:

  • Open a bounded number of files
  • Reuse or cache file handles where possible
  • Properly close file descriptors after use
  • Stabilize resource usage after initial context loading

Even in large repositories, file descriptor usage should remain within reasonable limits and not grow indefinitely.

Error Messages/Logs

Monitoring file descriptors:

lsof -p <PID> | wc -l

Observed growth:

t=0s   → ~500
t=2s   → ~8000
t=5s   → ~40000
t=10s  → ~65582
t=??s  → ~130000 (before crash)

System impact:
- Hits ulimit -n
- Android Studio starts failing (file access errors)
- Terminal and OS become unstable

No specific Claude error message is shown; failure manifests as resource exhaustion.

Steps to Reproduce

  1. Open a large Android/Kotlin monorepo (multi-module)
  2. Run Claude from the repository root:

claude

  1. Execute any simple task, e.g.:

"summarize this repository"
or
"open README"

  1. In parallel, monitor file descriptors:

lsof -p <CLAUDE_PID> | wc -l

Result:

  • File descriptors increase rapidly and continuously
  • No stabilization occurs
  • Eventually reaches tens of thousands (65k+) and up to ~130k before crash

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.117

Claude Code Version

2.1.117

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗