EBUSY: resource busy or locked on .claude.json with multiple concurrent sessions (Windows)

Resolved 💬 3 comments Opened Feb 14, 2026 by yaniv-tg Closed Feb 18, 2026

Bug Description

When running multiple concurrent Claude Code sessions on Windows, sessions crash with EBUSY: resource busy or locked when trying to write to ~/.claude.json. This file is a shared global state file that all Claude Code instances write to using writeFileSync, which causes file locking collisions on Windows.

Error Message

ERROR  EBUSY: resource busy or locked, open 'C:\Users\mail\.claude.json'

    at writeFileSync (unknown)
 Wq (B:/~BUN/root/claude.exe:6177:1226)
 R$f (B:/~BUN/root/claude.exe:6177:4302)
 FA (B:/~BUN/root/claude.exe:6177:2896)
 OC$ (B:/~BUN/root/claude.exe:3503:10084)

Environment

  • OS: Windows 10/11 (MINGW64_NT-10.0-26200)
  • Claude Code version: 2.1.42 (native install)
  • Concurrent sessions: ~14 Claude Code instances running simultaneously across different project directories
  • File system: Local NTFS (C: drive) - .claude.json is NOT on a network/cloud drive

Steps to Reproduce

  1. Open 10+ Claude Code sessions in different terminals, each in a different project directory
  2. Use them actively (tool calls, etc.)
  3. Eventually one or more sessions crash with the EBUSY error above

Expected Behavior

Multiple concurrent Claude Code sessions should be able to coexist without crashing. The ~/.claude.json global state file should handle concurrent access safely.

Root Cause Analysis

The crash occurs at writeFileSync in the Claude Code binary. On Windows, writeFileSync acquires an exclusive file lock. When multiple Claude Code instances try to write to the same ~/.claude.json file simultaneously, all but one get EBUSY.

Suggested Fixes

  1. Atomic writes: Write to a temp file, then rename (rename is atomic on NTFS)
  2. Retry with backoff: On EBUSY, retry the write after a short random delay
  3. Per-process state: Split the state file so each instance writes to its own file, with a merge on read
  4. File locking with retry: Use flock/advisory locking with retry logic instead of bare writeFileSync
  5. Environment variable for path: Allow CLAUDE_STATE_FILE or similar to override ~/.claude.json location

Workaround

Currently there is no workaround - ~/.claude.json is hardcoded to $HOME/.claude.json with no way to override it per instance.

Impact

This is a significant issue for users who work across multiple projects simultaneously. Power users running 10+ concurrent sessions experience frequent crashes, losing work in progress.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗