Handle Network errors in messaging sync

This commit is contained in:
Charles Bochet 2024-06-09 09:59:55 +02:00
parent e4a4499b79
commit 01c0378b7a

View File

@ -18,7 +18,7 @@ type SyncStep =
| 'messages-import';
export type GmailError = {
code: number;
code: number | string;
reason: string;
};
@ -94,7 +94,21 @@ export class MessagingErrorHandlingService {
workspaceId,
);
break;
case 'ECONNRESET':
case 'ENOTFOUND':
case 'ECONNABORTED':
case 'ETIMEDOUT':
case 'ERR_NETWORK':
// We are currently mixing up Gmail Error code (HTTP status) and axios error code (ECONNRESET)
// In case of a network error, we should retry the request
await this.handleRateLimitExceeded(
error,
syncStep,
messageChannel,
workspaceId,
);
break;
default:
await this.messagingChannelSyncStatusService.markAsFailedUnknownAndFlushMessagesToImport(
messageChannel.id,