Skip to content

Commit 3c06400

Browse files
chivorotkivsergeibbb
authored andcommitted
Avoids continuous refreshing when GKDev cannot renew expired session
(#4324)
1 parent 4e1b411 commit 3c06400

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/plus/integrations/models/integration.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ export abstract class IntegrationBase<
237237
requestSessionSyncForUsecase(syncReqUsecase: SyncReqUsecase): void {
238238
this._syncRequestsPerFailedUsecase.add(syncReqUsecase);
239239
}
240+
private refreshDueToExpirationRequested = false;
240241
private static readonly requestExceptionLimit = 5;
241242
private requestExceptionCount = 0;
242243

@@ -338,9 +339,14 @@ export abstract class IntegrationBase<
338339
private missingExpirityReported = false;
339340
@gate()
340341
protected async refreshSessionIfExpired(scope?: LogScope): Promise<void> {
341-
if (this._session?.expiresAt != null && this._session.expiresAt < new Date()) {
342+
if (
343+
!this.refreshDueToExpirationRequested &&
344+
this._session?.expiresAt != null &&
345+
this._session.expiresAt < new Date()
346+
) {
342347
// The current session is expired, so get the latest from the cloud and refresh if needed
343348
try {
349+
this.refreshDueToExpirationRequested = true;
344350
await this.syncCloudConnection('connected', true);
345351
} catch (ex) {
346352
Logger.error(ex, scope);
@@ -430,6 +436,9 @@ export abstract class IntegrationBase<
430436

431437
this._session = session ?? null;
432438
this.smoothifyRequestExceptionCount();
439+
if (this._session?.expiresAt == null || this._session.expiresAt > new Date()) {
440+
this.refreshDueToExpirationRequested = false;
441+
}
433442

434443
if (session != null) {
435444
await this.container.storage.storeWorkspace(this.connectedKey, true);

0 commit comments

Comments
 (0)