Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[auth] Attempt to refresh token 3 times EXP-1413 #19452

Merged
merged 6 commits into from
Feb 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix
  • Loading branch information
easyCZ committed Feb 21, 2024
commit 89e766d64b0d93c1feec7ea5991966eaf4280c13
4 changes: 4 additions & 0 deletions components/server/src/user/token-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export class TokenService implements TokenProvider {

if (authProvider.refreshToken) {
const errors: Error[] = [];

// There is a race condition where multiple requests may each need to use the refresh_token to get a new access token.
// When the `authProvider.refreshToken` is called, it will refresh the token and store it in the database.
// However, the token may have already been refreshed by another request, so we need to check the database again.
for (let i = 0; i < 3; i++) {
try {
await authProvider.refreshToken(user);
Expand Down
Loading