Startup crashes with misleading fd error when project has many session files
Resolved 💬 2 comments Opened May 21, 2026 by bettercallwesley Closed May 25, 2026
Bug description
Claude Code crashes on startup when a project has accumulated a large number of session history files (.jsonl) in ~/.claude/projects/<project>/. The error message incorrectly attributes the failure to low file descriptor limits.
Error message shown
error: An unknown error occurred, possibly due to low max file descriptors (Unexpected)
Current limit: 256
To fix this, try running:
ulimit -n 2147483646
Actual cause
The file descriptor limit is not the problem. Claude Code reads all .jsonl session files in the project directory at startup. When a project accumulates enough sessions (~100+ files, ~100+ MB), the startup parser fails.
Reproduction
- Use Claude Code in a project over many sessions (we had 149 sessions, 135 MB total in
.jsonlfiles) - Attempt to launch
claudein that project directory - Startup crashes with the fd error above
- The suggested
ulimit -n 2147483646fix does not work (and exceeds the macOS kernel cap anyway)
Diagnostic proof
ulimit -nwas already set to 1,048,576 — well above 256. The error message was wrong.- Launching Claude Code from a clean temp directory (
/tmp/claude-test) worked fine. - Moving the 149
.jsonlfiles out of~/.claude/projects/<project>/immediately fixed the startup crash. - Three separate projects (145, 149, and 101 sessions) all had this issue.
Environment
- macOS (Darwin 25.3.0)
- Claude Code installed via npm global (
~/.npm-global/bin/claude) - Node.js v22.14.0
Expected behavior
- Startup should not choke on session history. Either lazy-load sessions, cap what's read at startup, or implement built-in session retention/pruning.
- There should be a built-in config option for session retention (e.g.,
maxSessionAge,maxSessionCount). - The error message should be accurate. If the failure is an OOM or parse timeout from large session state, say that — not "low max file descriptors."
Workaround
Manually pruning old .jsonl files from ~/.claude/projects/<project>/ resolves the issue. A cron job with find ~/.claude/projects -name '*.jsonl' -mtime +30 -delete prevents recurrence.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗