Parallel sessions crash simultaneously on Windows (native install)

Status Fixed / completed
Reported on v2.1.50
Maintainer reply None cached
Activity 5 comments · opened Feb 22, 2026 · closed Feb 23, 2026

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

  1. Open two separate terminal windows
  2. Launch claude in each terminal, working on different branches/worktrees
  3. Both sessions actively working (using subagents, API calls, tool use)
  4. 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 / flock equivalent on Windows) for shared state writes

View original on GitHub ↗

5 Comments

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/3117
  2. https://github.com/anthropics/claude-code/issues/13287
  3. https://github.com/anthropics/claude-code/issues/15079

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

mauropecchia82-svg · 7 months ago

Update: Workaround Found

After further investigation of the cli.js source (v2.1.50), we identified that the root cause is not the ~/.claude.json race condition, but rather the auto-migrate-to-native mechanism (qL1() function in cli.js).

What happens

Every time Claude Code starts, it checks whether it should migrate to the native Windows installation. When multiple sessions are running, this migration process kills and restarts the process — taking down all parallel sessions simultaneously.

The fix

Set the environment variable DISABLE_AUTO_MIGRATE_TO_NATIVE=1 to prevent the auto-migration check.

We added it to ~/.claude/settings.json:

{
  "env": {
    "DISABLE_AUTO_MIGRATE_TO_NATIVE": "1"
  }
}

Other findings

  • autoUpdatesChannel in settings only accepts "latest" or "stable" — setting it to "disabled" causes a validation error (silent, but may contribute to instability)
  • The native migration is a separate mechanism from auto-updates, controlled exclusively by the env var above

Result

After applying this fix, we've been running parallel sessions (multiple terminals, worktrees, subagents) without any crash. The sessions remain stable and independent as expected.

mauropecchia82-svg · 7 months ago

Confirmed Fix — Stable after 24h+

The workaround described in my previous comment has been confirmed working after multiple sessions over 24+ hours. Two environment variables provide full protection:

  1. DISABLE_AUTO_MIGRATE_TO_NATIVE=1 — prevents the auto-migration check (qL1()) that was killing all parallel sessions
  2. DISABLE_INSTALLATION_CHECKS=1 — suppresses the yellow "switched from npm to native" warning message (controlled by a separate mechanism, key npm-deprecation-warning in cli.js)

Both are set as permanent Windows user-scope environment variables (via [Environment]::SetEnvironmentVariable(..., 'User')) and as backup in ~/.claude/settings.json env section.

Summary

  • Root cause: qL1() auto-migrate function runs at startup, reads process.env of the main process before settings.json env is applied (which only affects subprocesses via q16()). This race condition caused the migration process to kill all running sessions.
  • Solution: Setting the env var at OS level (Windows registry, User scope) ensures it's available to any process from startup.
  • Result: Parallel sessions (multiple terminals, worktrees, subagents) are fully stable.

I'd suggest documenting DISABLE_AUTO_MIGRATE_TO_NATIVE and DISABLE_INSTALLATION_CHECKS as official env vars for users who need to control this behavior, especially on Windows with parallel sessions.

mauropecchia82-svg · 7 months ago

Closing as resolved. Fix confirmed stable after 24h+ of parallel sessions. See last two comments for the full workaround (env vars DISABLE_AUTO_MIGRATE_TO_NATIVE + DISABLE_INSTALLATION_CHECKS at OS level).

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.