Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/app-store/googlecalendar/lib/CalendarAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
],
},
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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({
Expand Down
Loading