claude-code - 💡(How to fix) Fix [BUG] File descriptor leak regression in large monorepos (2.1.143+)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

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.

Fix Action

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

Code Example

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.

---

# 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
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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
  4. Monitor file descriptors in parallel: lsof -p $(pgrep claude) | wc -l
  5. 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)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] File descriptor leak regression in large monorepos (2.1.143+)