diff --git a/packages/app-store/googlecalendar/lib/CalendarAuth.ts b/packages/app-store/googlecalendar/lib/CalendarAuth.ts index 6ead261afb5a02..02ab5887cf7a21 100644 --- a/packages/app-store/googlecalendar/lib/CalendarAuth.ts +++ b/packages/app-store/googlecalendar/lib/CalendarAuth.ts @@ -303,6 +303,17 @@ export class CalendarAuth { return new calendar_v3.Calendar({ auth: googleAuthClient, + retryConfig: { + retry: 3, + noResponseRetries: 2, + httpMethodsToRetry: ["GET", "HEAD", "PUT", "OPTIONS", "DELETE", "PATCH", "POST"], + statusCodesToRetry: [ + [100, 199], + [403, 403], + [429, 429], + [500, 599], + ], + }, }); } } diff --git a/packages/app-store/googlecalendar/lib/__tests__/CalendarService.auth.test.ts b/packages/app-store/googlecalendar/lib/__tests__/CalendarService.auth.test.ts index 4cf07433ef9991..4b93fd5df22769 100644 --- a/packages/app-store/googlecalendar/lib/__tests__/CalendarService.auth.test.ts +++ b/packages/app-store/googlecalendar/lib/__tests__/CalendarService.auth.test.ts @@ -193,9 +193,11 @@ describe("GoogleCalendarService credential handling", () => { expectOAuth2InstanceToBeCreated(); - expect(calendarMock.calendar_v3.Calendar).toHaveBeenCalledWith({ - auth: getLastCreatedOAuth2Client(), - }); + expect(calendarMock.calendar_v3.Calendar).toHaveBeenCalledWith( + expect.objectContaining({ + auth: getLastCreatedOAuth2Client(), + }) + ); await expectCredentialsInDb([ expect.objectContaining({ id: regularCredential.id, @@ -205,6 +207,24 @@ describe("GoogleCalendarService credential handling", () => { }); }); + describe("retryConfig", () => { + test("calendar client is instantiated with retryConfig that includes PATCH, POST and 403 for rate limit retries", async () => { + const regularCredential = await createCredentialForCalendarService(); + mockSuccessfulCalendarListFetch(); + const calendarService = BuildCalendarService(regularCredential); + await calendarService.listCalendars(); + + expect(calendarMock.calendar_v3.Calendar).toHaveBeenCalledWith( + expect.objectContaining({ + retryConfig: expect.objectContaining({ + httpMethodsToRetry: expect.arrayContaining(["PATCH", "POST"]), + statusCodesToRetry: expect.arrayContaining([[403, 403]]), + }), + }) + ); + }); + }); + describe("Delegation Credential Error handling", () => { test("handles clientId not added to Google Workspace Admin Console error", async () => { const credentialWithDelegation = await createInMemoryDelegationCredentialForBuildCalendarService({