Add TwentyORM query read timeout exception (#13603)
In this PR: - adding a try / catch around all ORM internal methods save, insert, upsert, findOne, ... - leveraging this error to prevent messageChannels to get FAILED - optimizing messaging BATCH_SIZE and THROTTLE threshold according to local tests - <img width="1510" height="851" alt="image" src="https://github.com/user-attachments/assets/802fd933-caac-4291-9cde-34a1ddf59c06" />
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
export const MESSAGING_THROTTLE_MAX_ATTEMPTS = 4;
|
||||
export const MESSAGING_THROTTLE_MAX_ATTEMPTS = 5;
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
export const MESSAGING_GMAIL_USERS_MESSAGES_GET_BATCH_SIZE = 200;
|
||||
export const MESSAGING_GMAIL_USERS_MESSAGES_GET_BATCH_SIZE = 400;
|
||||
|
||||
+7
-2
@@ -3,6 +3,10 @@ import { Injectable } from '@nestjs/common';
|
||||
import { isDefined } from 'class-validator';
|
||||
|
||||
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
|
||||
import {
|
||||
TwentyORMException,
|
||||
TwentyORMExceptionCode,
|
||||
} from 'src/engine/twenty-orm/exceptions/twenty-orm.exception';
|
||||
import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager';
|
||||
import { MessageChannelSyncStatusService } from 'src/modules/messaging/common/services/message-channel-sync-status.service';
|
||||
import {
|
||||
@@ -36,7 +40,7 @@ export class MessageImportExceptionHandlerService {
|
||||
) {}
|
||||
|
||||
public async handleDriverException(
|
||||
exception: MessageImportDriverException | Error,
|
||||
exception: MessageImportDriverException | Error | TwentyORMException,
|
||||
syncStep: MessageImportSyncStep,
|
||||
messageChannel: Pick<
|
||||
MessageChannelWorkspaceEntity,
|
||||
@@ -53,6 +57,7 @@ export class MessageImportExceptionHandlerService {
|
||||
workspaceId,
|
||||
);
|
||||
break;
|
||||
case TwentyORMExceptionCode.QUERY_READ_TIMEOUT:
|
||||
case MessageImportDriverExceptionCode.TEMPORARY_ERROR:
|
||||
case MessageNetworkExceptionCode.ECONNABORTED:
|
||||
case MessageNetworkExceptionCode.ENOTFOUND:
|
||||
@@ -102,7 +107,7 @@ export class MessageImportExceptionHandlerService {
|
||||
'id' | 'throttleFailureCount'
|
||||
>,
|
||||
workspaceId: string,
|
||||
exception: MessageImportDriverException,
|
||||
exception: { message: string },
|
||||
): Promise<void> {
|
||||
if (
|
||||
messageChannel.throttleFailureCount >= MESSAGING_THROTTLE_MAX_ATTEMPTS
|
||||
|
||||
Reference in New Issue
Block a user