@@ -237,6 +237,7 @@ export abstract class IntegrationBase<
237
237
requestSessionSyncForUsecase ( syncReqUsecase : SyncReqUsecase ) : void {
238
238
this . _syncRequestsPerFailedUsecase . add ( syncReqUsecase ) ;
239
239
}
240
+ private refreshDueToExpirationRequested = false ;
240
241
private static readonly requestExceptionLimit = 5 ;
241
242
private requestExceptionCount = 0 ;
242
243
@@ -338,9 +339,14 @@ export abstract class IntegrationBase<
338
339
private missingExpirityReported = false ;
339
340
@gate ( )
340
341
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
+ ) {
342
347
// The current session is expired, so get the latest from the cloud and refresh if needed
343
348
try {
349
+ this . refreshDueToExpirationRequested = true ;
344
350
await this . syncCloudConnection ( 'connected' , true ) ;
345
351
} catch ( ex ) {
346
352
Logger . error ( ex , scope ) ;
@@ -430,6 +436,9 @@ export abstract class IntegrationBase<
430
436
431
437
this . _session = session ?? null ;
432
438
this . smoothifyRequestExceptionCount ( ) ;
439
+ if ( this . _session ?. expiresAt == null || this . _session . expiresAt > new Date ( ) ) {
440
+ this . refreshDueToExpirationRequested = false ;
441
+ }
433
442
434
443
if ( session != null ) {
435
444
await this . container . storage . storeWorkspace ( this . connectedKey , true ) ;
0 commit comments