Skip to content

fix(opencode): dedupe concurrent Codex OAuth refreshes#28236

Merged
rekram1-node merged 2 commits into
anomalyco:devfrom
cooper-oai:cooper/opencode-codex-refresh-dedupe
May 21, 2026
Merged

fix(opencode): dedupe concurrent Codex OAuth refreshes#28236
rekram1-node merged 2 commits into
anomalyco:devfrom
cooper-oai:cooper/opencode-codex-refresh-dedupe

Conversation

@cooper-oai
Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #28234

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Codex OAuth refreshes are now shared while one refresh is already in flight. Without that guard, two requests that arrive after the access token has expired can both try to refresh the same rotating refresh token, which can leave the later request failing after the token has already changed.

This keeps the change local to the Codex auth loader and persists refreshed credentials once per shared refresh.

How did you verify your code works?

  • bun test test/plugin/codex.test.ts
  • bun typecheck

I also added a regression test that starts two Codex requests against expired auth state and verifies only one refresh request and one auth update occur.

Screenshots / recordings

N/A - no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@cooper-oai cooper-oai marked this pull request as ready for review May 18, 2026 20:29
@rekram1-node
Copy link
Copy Markdown
Collaborator

we try to avoid mocks or global overrides, so making a small change

@rekram1-node rekram1-node merged commit c64ac90 into anomalyco:dev May 21, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex OAuth refresh can race across concurrent expired requests

2 participants