[BUG] Claude Code freezes with memory leak when processing output with extremely long lines (minified files)
Resolved 💬 5 comments Opened Jan 21, 2026 by jhinrichsen Closed Mar 3, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report
- [x] I am using the latest version of Claude Code
Related Issue
This is related to but distinct from #17394 (Session Freeze on Large File Read Error). That issue was about file size exceeding 256KB. This issue is about line length regardless of file size.
Description
Claude Code freezes with 100%+ CPU and memory leak (~30MB/sec) when processing files or command output containing extremely long lines, such as minified JSON, JS, CSS, SVG, or XML.
Steps to Reproduce
# Create a minified file (few lines, very long)
cd /tmp && mkdir test-line-length && cd test-line-length
python3 -c "print('x' * 600000)" > minified.txt
wc -l minified.txt # Shows: 1 line
ls -lh minified.txt # Shows: ~600KB
claude
# Ask: "read minified.txt"
What happens
- Read tool fails with "exceeds maximum size" error
- Claude falls back to
head -100 minified.txt - Since file has only 1 line,
headreturns the entire 600KB line - Claude freezes in "Baking..." state
- CPU spikes to 140%+, memory leaks at ~30MB/sec
- Terminal unresponsive, Ctrl+C ignored
Root Cause
The issue is line count ≠ byte count. Commands like head -N limit by lines, not bytes. A minified file can have millions of characters on a single line.
Real-world example
- File size: 2.9MB
- Line count: 5
- Average line length: ~580KB
head -100 would return nearly the entire file.
Diagnostic data (from strace)
futex(..., FUTEX_WAIT_PRIVATE, ...) = -1 EAGAIN (spinning)
mmap(...) allocating new memory repeatedly
Process state: No TCP connections (not waiting on API), pure CPU spin loop.
Environment
- Claude Code: v2.1.12
- Platform: Linux (Fedora)
- Terminal: Standard
Expected behavior
- Detect long lines before processing
- Truncate by bytes, not just lines
- Fail gracefully without freezing
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗