[BUG] Race condition in .claude.json config writes causes "Unexpected EOF" on concurrent startups

Resolved 💬 1 comment Opened Jun 4, 2026 by pradyot7 Closed Jul 9, 2026

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):

  1. open(file, O_TRUNC) — file is now empty
  2. write(new JSON content) — race window here
  3. close()

A concurrent reader between steps 1 and 2 sees an empty/partial file.

## Steps to Reproduce

  1. Open multiple terminals and launch claude (or claude --dangerously-skip-permissions) simultaneously
  2. One or more instances may fail with JSON Parse error: Unexpected EOF
  3. 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():

  1. Write to .claude.json.tmp
  2. 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():

  1. Write to .claude.json.tmp
  2. 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

  1. Open multiple terminals and launch claude (or claude --dangerously-skip-permissions) simultaneously
  2. One or more instances may fail with JSON Parse error: Unexpected EOF
  3. 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" />

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗