[BUG] File descriptor leak regression in large monorepos (2.1.143+)

Open 💬 7 comments Opened May 21, 2026 by rcgonzalezf

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 Code versions 2.1.143 and 2.1.145 exhibit a file descriptor leak when working with large Android/Kotlin monorepos. This appears to be a regression of #51933.

The leak causes:

  • System freezes requiring hard reboot
  • File system corruption affecting Git index and IDE metadata
  • In severe cases, developers have needed to reimage their machines

Multiple developers on large monorepo projects are affected. The issue was not present in version 2.1.126.

What Should Happen?

Claude should maintain stable file descriptor usage in large repositories without:

  • Exhausting system file handle limits
  • Causing system-level freezes
  • Corrupting git metadata or IDE files
  • Requiring system reboots or machine reimaging

Error Messages/Logs

error: An unknown error occurred, possibly due to low max file descriptors (Unexpected)

Current limit: 10240

To fix this, try running:

  ulimit -n 2147483646

If that still doesn't work, you may need to run:

  sudo launchctl limit maxfiles 2147483646

In reality the laptop freezes and restarts, the agent just tries to increase the `ulimit` and that aggravates the issue.

Steps to Reproduce

  1. Open a large Android/Kotlin monorepo (multi-module project with 100+ modules)
  2. Start Claude Code version 2.1.143 or 2.1.145
  3. Execute any task (the issue appears random but common triggers include):
  • Running /plan mode
  • Extended coding sessions
  • Basic file operations across modules
  1. Monitor file descriptors in parallel: lsof -p $(pgrep claude) | wc -l
  2. Within 10-30 minutes, observe:
  • File descriptor count climbing rapidly
  • System becoming unresponsive
  • Terminal showing permission errors after recovery

Repository characteristics:

  • Large multi-module Android project
  • ~100+ Gradle modules
  • Significant .gradle and .idea metadata

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.126

Claude Code Version

2.1.143 and 2.1.145 (both affected)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Workaround

Downgrading to version 2.1.126 resolves the issue completely:

# 1. Install target version
curl -fsSL https://claude.ai/install.sh | bash -s 2.1.126
# 2. Remove higher versions to prevent auto-update
rm -rf ~/.local/share/claude/versions/2.1.143
rm -rf ~/.local/share/claude/versions/2.1.145
# 3. Verify symlink points to 2.1.126
ls -la ~/.local/bin/claude

Impact

Multiple developers blocked from upgrading
Corrupted git metadata requiring repository re-cloning
IDE index rebuilds taking 1+ hours post-recovery
Some cases requiring complete machine reimaging
Development teams staying on 2.1.126 indefinitely
Request
This issue is blocking adoption for developers working with large monorepos. Since #51933 was closed due to inactivity (not confirmed resolution), this may indicate the underlying issue was never fully addressed.

Could the team:

Investigate what changed between 2.1.126 and 2.1.143 related to file handle management?
Consider re-opening #51933 or tracking this as a separate regression?
Add regression tests for large monorepo scenarios to prevent this from recurring?
Provide guidance on whether there are configuration options to limit file scanning depth or concurrent file operations?
Happy to provide additional diagnostics, repository structure details, or assist with testing fixes.

Related Issues

#51933 (original report, closed due to inactivity)
#29573 (similar symptoms)

View original on GitHub ↗

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