[Bug] OAuth refresh token race condition in multi-instance scenarios
Bug Description
❯ It seems like this issue happens intermittently when more than one claude instance is running on this machine. One instance will
update the token, continue successful communication with the MCP server, but other instances will try to renew the OAuth token
(same as the first one), but the server will reject the renewal as it already happened. Then those instances usually need a
restart to pick up new token.
⏺ That's a great diagnosis. Classic OAuth refresh token race condition:
- Instance A refreshes token → server invalidates old refresh token, issues new one
- Instance B (still has old refresh token) tries to refresh → server rejects because old token was revoked
- Instance B shows "Failed to reconnect" until restarted to pick up the new token from shared storage
This is a known challenge with OAuth in multi-instance scenarios. The fix would typically involve:
- Token refresh locking/coordination between instances
- Or: server-side refresh token rotation that allows brief grace period for old tokens
- Or: Claude Code detecting "refresh token invalid" and re-reading from storage before giving up
You can submit feedback using /bug or by reporting at https://github.com/anthropics/claude-code/issues with details about:
- Multiple instances sharing ~/.claude.json / ~/.claude/.credentials.json
- Race condition on HTTP MCP OAuth token refresh
- The debug log pattern showing the failure
For now, restarting the affected instance (as you noted) is the workaround.
Environment Info
- Platform: darwin
- Terminal: ghostty
- Version: 2.1.29
- Feedback ID: 37039963-4be1-4a0f-a815-b453c98ec6ed
Errors
[{"error":"MaxFileReadTokenExceededError: File content (25567 tokens) exceeds maximum allowed tokens (25000). Please use offset and limit parameters to read specific portions of the file, or use the GrepTool to search for specific content.\n at RVB (/$bunfs/root/claude:3523:5255)\n at async call (/$bunfs/root/claude:3532:1511)\n at async <anonymous> (/$bunfs/root/claude:3544:1608)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-02-02T19:41:59.164Z"},{"error":"MaxFileReadTokenExceededError: File content (66317 tokens) exceeds maximum allowed tokens (25000). Please use offset and limit parameters to read specific portions of the file, or use the GrepTool to search for specific content.\n at RVB (/$bunfs/root/claude:3523:5255)\n at async call (/$bunfs/root/claude:3532:1511)\n at async <anonymous> (/$bunfs/root/claude:3544:1608)\n at processTicksAndRejections (native:7:39)","timestamp":"2026-02-02T19:42:09.098Z"}]This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗