[BUG] Race condition in .claude.json config writes causes "Unexpected EOF" on concurrent startups
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 multiple Claude Code sessions start simultaneously, the config file at ~/.claude.json
can be read while another process is mid-write, resulting in:
Configuration Error
The configuration file at /home/user/.claude.json contains invalid JSON.
JSON Parse error: Unexpected EOF
## Root Cause
The config file appears to be written non-atomically (truncate-then-write):
open(file, O_TRUNC)— file is now emptywrite(new JSON content)— race window hereclose()
A concurrent reader between steps 1 and 2 sees an empty/partial file.
## Steps to Reproduce
- Open multiple terminals and launch
claude(orclaude --dangerously-skip-permissions) simultaneously - One or more instances may fail with
JSON Parse error: Unexpected EOF - I am using Vscode(Windows) +Linux environment both simultaneously , sharing same claude.json.
## Expected Behavior
Config writes should be atomic using write-to-tempfile + rename():
- Write to
.claude.json.tmp rename(.claude.json.tmp, .claude.json)— atomic on POSIX
This guarantees readers see either the old or new complete file, never a partial write.
## Environment
- OS: Linux 6.8.0-90-generic
- Claude Code version: 2.1.84
What Should Happen?
Config writes should be atomic using write-to-tempfile + rename():
- Write to
.claude.json.tmp rename(.claude.json.tmp, .claude.json)— atomic on POSIX
This guarantees readers see either the old or new complete file, never a partial write.
Error Messages/Logs
─
Configuration Error
The configuration file at /usr2/pradyotk/.claude.json contains invalid JSON.
JSON Parse error: Unexpected EOF
Choose an option:
1. Exit and fix manually
❯ 2. Reset with default configuration
Steps to Reproduce
- Open multiple terminals and launch
claude(orclaude --dangerously-skip-permissions) simultaneously - One or more instances may fail with
JSON Parse error: Unexpected EOF - I am using Vscode(Windows) +Linux environment both simultaneously , sharing same claude.json.
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.84
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Xterm
Additional Information
<img width="911" height="420" alt="Image" src="https://github.com/user-attachments/assets/aabcd8a0-c38e-4028-89f0-c09e8e5374c5" />
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗