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:
Charles Bochet
2025-08-04 17:16:16 +02:00
committed by GitHub
parent d958447bb6
commit 2eeddcddc6
14 changed files with 656 additions and 553 deletions
@@ -0,0 +1,23 @@
import { t } from '@lingui/core/macro';
import { QueryFailedError } from 'typeorm';
import {
TwentyORMException,
TwentyORMExceptionCode,
} from 'src/engine/twenty-orm/exceptions/twenty-orm.exception';
export const computeTwentyORMException = (error: Error) => {
if (error instanceof QueryFailedError) {
if (error.message.includes('Query read timeout')) {
return new TwentyORMException(
'Query read timeout',
TwentyORMExceptionCode.QUERY_READ_TIMEOUT,
{
userFriendlyMessage: t`We are experiencing a temporary issue with our database. Please try again later.`,
},
);
}
}
return error;
};