From 7c6ca0e841bf471f4f4eb0de23794b2b9e962318 Mon Sep 17 00:00:00 2001 From: martmull Date: Thu, 25 Jul 2024 08:38:05 +0200 Subject: [PATCH] Fix api timeout (#6401) --- .../workspace-query-runner/workspace-query-runner.service.ts | 4 +++- .../utils/map-field-metadata-to-graphql-query.utils.ts | 2 +- .../open-api/utils/__tests__/parameters.utils.spec.ts | 1 + .../engine/core-modules/open-api/utils/parameters.utils.ts | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts index 1ab7764f55..57f1029055 100644 --- a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts +++ b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/workspace-query-runner.service.ts @@ -643,7 +643,9 @@ export class WorkspaceQueryRunnerService { ); } catch (error) { if (isQueryTimeoutError(error)) { - throw new RequestTimeoutException(error.message); + throw new RequestTimeoutException( + 'The SQL request took too long to process, resulting in a query read timeout. To resolve this issue, consider modifying your query by reducing the depth of relationships or limiting the number of records being fetched.', + ); } throw error; diff --git a/packages/twenty-server/src/engine/api/rest/core/query-builder/utils/map-field-metadata-to-graphql-query.utils.ts b/packages/twenty-server/src/engine/api/rest/core/query-builder/utils/map-field-metadata-to-graphql-query.utils.ts index a34cc2123f..8b22e2f710 100644 --- a/packages/twenty-server/src/engine/api/rest/core/query-builder/utils/map-field-metadata-to-graphql-query.utils.ts +++ b/packages/twenty-server/src/engine/api/rest/core/query-builder/utils/map-field-metadata-to-graphql-query.utils.ts @@ -1,7 +1,7 @@ import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity'; import { RelationMetadataType } from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity'; -const DEFAULT_DEPTH_VALUE = 2; +const DEFAULT_DEPTH_VALUE = 1; // TODO: Should be properly type and based on composite type definitions export const mapFieldMetadataToGraphqlQuery = ( diff --git a/packages/twenty-server/src/engine/core-modules/open-api/utils/__tests__/parameters.utils.spec.ts b/packages/twenty-server/src/engine/core-modules/open-api/utils/__tests__/parameters.utils.spec.ts index f91da6a750..a4f6b6fcc0 100644 --- a/packages/twenty-server/src/engine/core-modules/open-api/utils/__tests__/parameters.utils.spec.ts +++ b/packages/twenty-server/src/engine/core-modules/open-api/utils/__tests__/parameters.utils.spec.ts @@ -69,6 +69,7 @@ describe('computeParameters', () => { schema: { type: 'integer', enum: [0, 1, 2], + default: 1, }, }); }); diff --git a/packages/twenty-server/src/engine/core-modules/open-api/utils/parameters.utils.ts b/packages/twenty-server/src/engine/core-modules/open-api/utils/parameters.utils.ts index 56034403a9..954e567e85 100644 --- a/packages/twenty-server/src/engine/core-modules/open-api/utils/parameters.utils.ts +++ b/packages/twenty-server/src/engine/core-modules/open-api/utils/parameters.utils.ts @@ -60,6 +60,7 @@ export const computeDepthParameters = (): OpenAPIV3_1.ParameterObject => { schema: { type: 'integer', enum: [0, 1, 2], + default: 1, }, }; };