fix: always refresh with retries

Even if an access token is expired, the refresh token could be valid. They don't expire until much longer
This commit is contained in:
Nate 2025-07-07 22:59:52 -07:00
parent 87d0f94171
commit ebfb1922f5

View file

@ -198,12 +198,9 @@ export class WorkOsAuthProvider implements AuthenticationProvider, Disposable {
const finalSessions = [];
for (const session of sessions) {
try {
// For expired tokens, don't use retries - if refresh fails, we drop the session
const refreshMethod = this.jwtIsExpiredOrInvalid(session.accessToken)
? this._refreshSession.bind(this) // Direct refresh for expired tokens
: this._refreshSessionWithRetry.bind(this); // Retry for valid tokens
const newSession = await refreshMethod(session.refreshToken);
const newSession = await this._refreshSessionWithRetry(
session.refreshToken,
);
finalSessions.push({
...session,
accessToken: newSession.accessToken,