Skip to content

fix: prevent concurrent token refreshes#26530

Open
code-asher wants to merge 2 commits into
mainfrom
asher/concurrent-token-refresh
Open

fix: prevent concurrent token refreshes#26530
code-asher wants to merge 2 commits into
mainfrom
asher/concurrent-token-refresh

Conversation

@code-asher

@code-asher code-asher commented Jun 18, 2026

Copy link
Copy Markdown
Member

This can cause bad refresh token errors, since it can only be used once.

Looks like there was an attempt to fix this by checking the database after a failed refresh, but of course this depends on the first request having updated the database in time...

@Emyrk does my fix look like it makes sense? One thing I was not sure about is if there can be multiple replicas writing in which case I actually will need a database-level lock...

Closes https://linear.app/codercom/issue/DEVEX-498/fix-external-oauth-refresh-race

and the original error report is https://linear.app/codercom/issue/DEVEX-432/github-oauth-refresh-unreliability

Comment on lines +152 to +154
// TestSubscribeChannel can be used in tests to wait for all callers to
// subscribe to a refresh.
TestSubscribeChannel chan string

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this dumb? It feels kinda dumb lol. But not sure how else to properly wait, otherwise the test will flake 😢

@linear-code

linear-code Bot commented Jun 18, 2026

Copy link
Copy Markdown

DEVEX-498

@datadog-coder

This comment has been minimized.

This can cause bad refresh token errors, since it can only be used once.
@code-asher code-asher force-pushed the asher/concurrent-token-refresh branch from 71bc56f to 551304b Compare June 18, 2026 20:02
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.

1 participant