[Bug] Concurrent config writes corrupt `.claude.json` on Windows startup
Bug Description
## Bug Description
.claude.json config file gets corrupted (JSON Parse error: Unexpected EOF)
during startup due to a concurrent atomic write race condition on Windows.
## Steps to Reproduce
- Launch Claude Code on Windows 11
- Multiple internal components (LSP init, MCP connections, config cache
updates) attempt to write .claude.json simultaneously during startup
- Config file ends up truncated/corrupted
## Error Logs (from debug session)
Failed to save config with lock: Error: Lock file is already being held (×6)
Failed to write file atomically: Error: EPERM: operation not permitted,
rename '.claude.json.tmp.32508' -> '.claude.json'
Config file corrupted, resetting to defaults: JSON Parse error: Unexpected EOF
## Root Cause Analysis
The atomic write pattern (write to .tmp → rename to target) fails on Windows
when multiple internal writers contend for the same file. Windows rename()
returns EPERM if the target file handle is held by another process, breaking
the atomicity guarantee and leaving a truncated file on disk.
## Environment
- OS: Windows 11 Pro 10.0.26200
- Claude Code: 2.1.59
- Shell: bash (Git Bash)
## Current Behavior
Claude Code auto-detects the corruption, backs up the corrupted file, and
resets to defaults. Recovery works but some transient state (tool usage stats,
feature flags) may be lost.
## Expected Behavior
Concurrent config writes during startup should be serialized or use a
Windows-safe file locking mechanism to prevent corruption.
Environment Info
- Platform: win32
- Terminal: windows-terminal
- Version: 2.1.59
- Feedback ID: b5cb32e4-081c-4e59-8d4f-3cbc7e45e284
Errors
[{"error":"Error: Failed to initialize LSP server plugin:powershell-editor-services:powershell: LSP server 'plugin:powershell-editor-services:powershell': shutdownTimeout is not yet implemented. Remove this field from the configuration.\n at L (B:/~BUN/root/claude.exe:2692:32647)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-02-26T03:54:14.562Z"},{"error":"Error: LSP server plugin:vtsls:typescript failed to start: ENOENT: no such file or directory, uv_spawn 'vtsls'\n at start (B:/~BUN/root/claude.exe:2692:22116)\n at async E (B:/~BUN/root/claude.exe:2692:24428)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-02-26T03:54:14.563Z"},{"error":"Error: ENOENT: no such file or directory, uv_spawn 'vtsls'\n at spawn (unknown)\n at spawn (node:child_process:679:35)\n at spawn (node:child_process:14:39)\n at start (B:/~BUN/root/claude.exe:2692:20642)\n at E (B:/~BUN/root/claude.exe:2692:24428)\n at L (B:/~BUN/root/claude.exe:2692:32556)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-02-26T03:54:14.563Z"},{"error":"Error: Failed to start LSP server plugin:vtsls:typescript: ENOENT: no such file or directory, uv_spawn 'vtsls'\n at <anonymous> (B:/~BUN/root/claude.exe:2692:32578)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-02-26T03:54:14.563Z"},{"error":"ConfigParseError: JSON Parse error: Unexpected EOF\n at g$H (B:/~BUN/root/claude.exe:6269:7698)\n at BA (B:/~BUN/root/claude.exe:6269:3774)\n at E_0 (B:/~BUN/root/claude.exe:141:4507)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-02-26T03:54:17.609Z"}]This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗