The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Handle Microsoft calendar sync cursor error (#15938)
neo7735476879f77b4
diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/exceptions/calendar-event-import-driver.exception.ts b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/exceptions/calendar-event-import-driver.exception.tsindex f4c6c1b8ad5..b805e07f55e 100644--- a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/exceptions/calendar-event-import-driver.exception.ts+++ b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/exceptions/calendar-event-import-driver.exception.ts@@ -6,6 +6,7 @@ export enum CalendarEventImportDriverExceptionCode {NOT_FOUND = 'NOT_FOUND',TEMPORARY_ERROR = 'TEMPORARY_ERROR',INSUFFICIENT_PERMISSIONS = 'INSUFFICIENT_PERMISSIONS',+ SYNC_CURSOR_ERROR = 'SYNC_CURSOR_ERROR',UNKNOWN = 'UNKNOWN',UNKNOWN_NETWORK_ERROR = 'UNKNOWN_NETWORK_ERROR',}diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/microsoft-calendar/utils/parse-microsoft-calendar-error.util.ts b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/microsoft-calendar/utils/parse-microsoft-calendar-error.util.tsindex ecadb63f586..44f34dbf0dc 100644--- a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/microsoft-calendar/utils/parse-microsoft-calendar-error.util.ts+++ b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/microsoft-calendar/utils/parse-microsoft-calendar-error.util.ts@@ -33,6 +33,12 @@ export const parseMicrosoftCalendarError = (CalendarEventImportDriverExceptionCode.NOT_FOUND,);+ case 410:+ return new CalendarEventImportDriverException(+ message,+ CalendarEventImportDriverExceptionCode.SYNC_CURSOR_ERROR,+ );+case 429:return new CalendarEventImportDriverException(message,diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-event-import-exception-handler.service.ts b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-event-import-exception-handler.service.tsindex 39f941dd0fd..b479c0d072c 100644--- a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-event-import-exception-handler.service.ts+++ b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-event-import-exception-handler.service.ts@@ -64,6 +64,9 @@ export class CalendarEventImportErrorHandlerService {workspaceId,);break;+ case CalendarEventImportDriverExceptionCode.SYNC_CURSOR_ERROR:+ await this.handleSyncCursorErrorException(calendarChannel, workspaceId);+ break;case CalendarEventImportDriverExceptionCode.UNKNOWN:case CalendarEventImportDriverExceptionCode.UNKNOWN_NETWORK_ERROR:default:@@ -76,6 +79,20 @@ export class CalendarEventImportErrorHandlerService {}}+ private async handleSyncCursorErrorException(+ calendarChannel: Pick<CalendarChannelWorkspaceEntity, 'id'>,+ workspaceId: string,+ ): Promise<void> {+ this.logger.log(+ `CalendarChannelId: ${calendarChannel.id} - Sync cursor error, resetting and rescheduling`,+ );++ await this.calendarChannelSyncStatusService.resetAndScheduleCalendarEventListFetch(+ [calendarChannel.id],+ workspaceId,+ );+ }+private async handleTemporaryException(syncStep: CalendarEventImportSyncStep,calendarChannel: Pick<