[BUG] Infinite FileHistory loop when running multiple concurrent Claude Code sessions causes freeze
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?
Description
When running multiple Claude Code sessions simultaneously, one or more sessions can enter an infinite loop creating FileHistory snapshots, resulting in complete freeze with no token progress despite the timer continuing to increment. The debug log file grows to multi-GB sizes and CPU usage spikes to 100%+ while making no actual progress.
Environment
- Claude Code Version: 2.1.7
- Installation Method: npm (@anthropic-ai/claude-code)
- OS: macOS (Sonoma/Sequoia)
- Shell: zsh
- Multiple Sessions: Yes - 2-6 concurrent sessions running
What Should Happen?
Expected Behavior
- Multiple Claude Code sessions should run independently without interfering with each other
Sessions should either:
- Handle concurrent access gracefully with proper locking
- Warn the user that another session is running
- Queue operations safely
Workaround
Temporary fix: Run only one Claude Code session at a time
bash# Kill all existing sessions before starting new one
pkill claude
Then start single session
claude
After workaround applied: Sessions run normally with proper API streaming and token progression.
Impact
User Experience: Appears completely broken - timer runs but no work happens
Additional Context
- Issue started appearing in version 2.1.7
- Reinstalling Claude Code temporarily resolves until multiple sessions run again
- Issue occurs even when sessions are in different project directories
- VSCode extension also affected (uses same underlying binary)
Error Messages/Logs
Debug Log Pattern (Infinite Loop)
2026-01-15T16:51:07.752Z [DEBUG] FileHistory: Making snapshot for message eb8d526b-475f-4049-a1ca-b143703f436f
2026-01-15T16:51:07.764Z [DEBUG] FileHistory: Added snapshot for eb8d526b-475f-4049-a1ca-b143703f436f, tracking 3 files
2026-01-15T16:51:07.772Z [DEBUG] Writing to temp file: /Users/.claude.json.tmp.51250.1768495867772
2026-01-15T16:51:07.772Z [DEBUG] Preserving file permissions: 100644
2026-01-15T16:51:07.772Z [DEBUG] Temp file written successfully, size: 33108 bytes
2026-01-15T16:51:07.772Z [DEBUG] Renaming /Users/.claude.json.tmp.51250.1768495867772 to /Users/.claude.json
2026-01-15T16:51:07.772Z [DEBUG] File /Users/.claude.json written atomically
2026-01-15T16:51:07.784Z [DEBUG] LSP Diagnostics: getLSPDiagnosticAttachments called
2026-01-15T16:51:07.784Z [DEBUG] LSP Diagnostics: Checking registry - 0 pending
[... repeats infinitely ...]
Process Information
When frozen, multiple Claude processes compete for resources:
bash
$ ps aux | grep claude
userid51250 119.6 12.6 533367936 3163344 ?? R Wed08AM 1648:24.19 claude
userid95949 99.2 1.8 509700112 459216 s003 R+ 10:57AM 17:25.69 claude
userid87584 20.7 0.9 527431360 229856 ?? S 7:55AM 55:21.63 claude
[... more processes ...]
Debug File Sizes
bash
$ ls -lht ~/.claude/debug | head -5
-rw-r--r--@ 1 user staff 2.2G Jan 15 10:51 12d3be61-4630-485b-86b1-bda3c28a8ef0.txt
-rw-r--r--@ 1 user staff 199M Jan 15 12:55 12d3be61-4630-485b-86b1-bda3c28a8ef0.txt
-rw-r--r--@ 1 user staff 132K Jan 15 10:48 ae82d94a-47bc-4912-b5c5-d38649ab1052.txt [normal]
Steps to Reproduce
Actual Behavior
One or more sessions enter an infinite loop:
- Creates FileHistory snapshots continuously
- Writes .claude.json file repeatedly
- Runs LSP diagnostic checks in a loop
- Debug log file grows to multi-GB size (observed: 2.2GB+, 199MB+)
- CPU usage spikes to 99-119%
- No API requests are made (token count frozen)
- Session appears hung but doesn't timeout or error
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.7
Platform
AWS Bedrock
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗