Parallel sessions crash simultaneously on Windows (native install)
Description
Running two parallel Claude Code sessions (separate terminals, separate worktrees/branches) on Windows causes both sessions to terminate simultaneously without any logged error. This has happened twice since switching to the native Windows installation (v2.1.50).
Environment
- OS: Windows 11 Pro 10.0.26200
- Claude Code version: 2.1.50 (native installation, not npm)
- Installation: Native Windows installer
- Shell: bash (Git Bash)
Steps to Reproduce
- Open two separate terminal windows
- Launch
claudein each terminal, working on different branches/worktrees - Both sessions actively working (using subagents, API calls, tool use)
- After some time, both sessions terminate simultaneously
Expected Behavior
Each session should be independent — one crashing should not affect the other.
Actual Behavior
Both sessions die at the same time. No error message is displayed. Debug logs (~/.claude/debug/) show no fatal error — the process simply stops, suggesting an external kill.
Possible Root Cause
Debug logs show both sessions perform atomic writes to the same ~/.claude.json file using temp files + rename:
Renaming C:\Users\<user>\.claude.json.tmp.16576.1771764251179 to C:\Users\<user>\.claude.json
If both sessions attempt this simultaneously, there could be a race condition on Windows (where file rename semantics differ from POSIX). One session's rename could fail or corrupt the shared state, causing both to exit.
Additional Context
- Sessions use different git worktrees and branches (no shared git resources)
- Both sessions use subagents (Haiku + Opus), generating concurrent API connections
- The crash is not reproducible on demand — it seems to depend on timing of concurrent writes
- This did not happen (or was not noticed) before switching from npm to native installation
Suggested Fix
- Use per-session state files instead of a shared
~/.claude.json, or - Implement proper file locking (e.g.,
lockfile/flockequivalent on Windows) for shared state writes
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗