Catch query timeout exceptions (#5680)

Query read timeouts happen when a remote server is not available. It
breaks:
- the remote server show page
- the record table page of imported remote tables

This PR will catch the exception so it does not go to Sentry in both
cases.

Also did 2 renaming.
This commit is contained in:
Thomas Trompette
2024-05-31 10:39:35 +02:00
committed by GitHub
parent 5e1dfde3e4
commit c60a3e49cd
11 changed files with 101 additions and 63 deletions

View File

@ -10,6 +10,7 @@ import {
NotFoundError,
ConflictError,
MethodNotAllowedError,
TimeoutError,
} from 'src/engine/utils/graphql-errors.util';
import { ExceptionHandlerService } from 'src/engine/integrations/exception-handler/exception-handler.service';
@ -19,6 +20,7 @@ const graphQLPredefinedExceptions = {
403: ForbiddenError,
404: NotFoundError,
405: MethodNotAllowedError,
408: TimeoutError,
409: ConflictError,
};
@ -32,7 +34,7 @@ export const handleExceptionAndConvertToGraphQLError = (
return convertExceptionToGraphQLError(exception);
};
export const filterException = (exception: Error): boolean => {
export const shouldFilterException = (exception: Error): boolean => {
if (exception instanceof HttpException && exception.getStatus() < 500) {
return true;
}
@ -45,7 +47,7 @@ export const handleException = (
exceptionHandlerService: ExceptionHandlerService,
user?: ExceptionHandlerUser,
): void => {
if (filterException(exception)) {
if (shouldFilterException(exception)) {
return;
}

View File

@ -157,3 +157,11 @@ export class ConflictError extends BaseGraphQLError {
Object.defineProperty(this, 'name', { value: 'ConflictError' });
}
}
export class TimeoutError extends BaseGraphQLError {
constructor(message: string, extensions?: Record<string, any>) {
super(message, 'TIMEOUT', extensions);
Object.defineProperty(this, 'name', { value: 'TimeoutError' });
}
}

View File

@ -0,0 +1,3 @@
export const isQueryTimeoutError = (error: Error) => {
return error.message.includes('Query read timeout');
};