Description
With xAI SuperGrok OAuth, running multiple opencode processes (or opencode + Grok CLI sharing the same OAuth client) races on the stored refresh token.
xAI rotates refresh tokens. Process A refreshes successfully and invalidates the old token; process B still holds the old refresh value and gets:
xAI token refresh failed (400): {"error":"invalid_grant","error_description":"Refresh token has been revoked"}
In-process single-flight already exists in packages/opencode/src/plugin/xai.ts, but there is no cross-process coordination on auth.json. The code even comments this as a known cross-process limitation.
Plugins
None required (built-in xAI OAuth).
OpenCode version
1.18.1
Steps to reproduce
/connect xAI Grok OAuth (SuperGrok).
- Start several
opencode processes against the same machine/user home (shared ~/.local/share/opencode/auth.json).
- Wait until the access token is near expiry (~6h, or force by advancing system time / waiting for skew window).
- Trigger LLM calls in more than one process around the same time.
- Observe
invalid_grant / "Refresh token has been revoked" in one or more sessions.
Screenshot and/or share link
Log excerpt:
level=ERROR message="stream error" providerID=xai modelID=grok-4.5
error="xAI token refresh failed (400): {\"error\":\"invalid_grant\",\"error_description\":\"Refresh token has been revoked\"}"
Operating System
Linux (Ubuntu, x86_64)
Terminal
CLI / multiple concurrent sessions
Description
With xAI SuperGrok OAuth, running multiple
opencodeprocesses (or opencode + Grok CLI sharing the same OAuth client) races on the stored refresh token.xAI rotates refresh tokens. Process A refreshes successfully and invalidates the old token; process B still holds the old refresh value and gets:
In-process single-flight already exists in
packages/opencode/src/plugin/xai.ts, but there is no cross-process coordination onauth.json. The code even comments this as a known cross-process limitation.Plugins
None required (built-in xAI OAuth).
OpenCode version
1.18.1
Steps to reproduce
/connectxAI Grok OAuth (SuperGrok).opencodeprocesses against the same machine/user home (shared~/.local/share/opencode/auth.json).invalid_grant/ "Refresh token has been revoked" in one or more sessions.Screenshot and/or share link
Log excerpt:
Operating System
Linux (Ubuntu, x86_64)
Terminal
CLI / multiple concurrent sessions