Skip to content

Commit ba39cd8

Browse files
committed
Resets request exception count after token refresh
Resets the request exception count when a new access token is obtained after refreshing the session. This prevents the integration from being prematurely disconnected due to request errors associated with the old token. (#4324)
1 parent c179abf commit ba39cd8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/plus/integrations/models/integration.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ export abstract class IntegrationBase<
278278
}
279279

280280
switch (state) {
281-
case 'connected':
281+
case 'connected': {
282+
const oldSession = this._session;
282283
if (forceSync) {
283284
// Reset our stored session so that we get a new one from the cloud
284285
const authProvider = await this.authenticationService.get(this.authProvider.id);
@@ -301,8 +302,14 @@ export abstract class IntegrationBase<
301302

302303
// sync option, rather than createIfNeeded, makes sure we don't call connectCloudIntegrations and open a gkdev window
303304
// if there was no session or some problem fetching/refreshing the existing session from the cloud api
304-
await this.ensureSession({ sync: forceSync });
305+
const newSession = await this.ensureSession({ sync: forceSync });
306+
307+
if (oldSession && newSession && newSession.accessToken !== oldSession.accessToken) {
308+
this.resetRequestExceptionCount('all');
309+
}
310+
305311
break;
312+
}
306313
case 'disconnected':
307314
await this.disconnect({ silent: true });
308315
break;

0 commit comments

Comments
 (0)