Handle Microsoft calendar sync cursor error (#15938)

Resolves https://twenty-v7.sentry.io/issues/6567295627
This commit is contained in:
neo773
2025-11-20 21:02:44 +05:30
committed by GitHub
parent e5255df1a1
commit 5476879f77
3 changed files with 24 additions and 0 deletions
@@ -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',
}
@@ -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,
@@ -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<