The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Bound HTTP Request step duration and payload size (#27593)
Paul Rastoin43b824f7099c
diff --git a/packages/twenty-docs/user-guide/workflows/capabilities/workflow-actions.mdx b/packages/twenty-docs/user-guide/workflows/capabilities/workflow-actions.mdxindex 762435353c8..bdda042ab53 100644--- a/packages/twenty-docs/user-guide/workflows/capabilities/workflow-actions.mdx+++ b/packages/twenty-docs/user-guide/workflows/capabilities/workflow-actions.mdx@@ -303,6 +303,8 @@ Sends a request to an external API as part of your workflow.- Add required headers and values- Provide sample response for structure preview+**Limits**: the request fails if it takes longer than 30 seconds, or if the request or response body is larger than 10 MB.+## AI Actions### AI Agentdiff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/http-tool/constants/http-tool-max-payload-size-bytes.constant.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/http-tool/constants/http-tool-max-payload-size-bytes.constant.tsnew file mode 100644index 00000000000..426b69b14f3--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/tool/tools/http-tool/constants/http-tool-max-payload-size-bytes.constant.ts@@ -0,0 +1 @@+export const HTTP_TOOL_MAX_PAYLOAD_SIZE_BYTES = 10 * 1024 * 1024;diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/http-tool/constants/http-tool-timeout-ms.constant.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/http-tool/constants/http-tool-timeout-ms.constant.tsnew file mode 100644index 00000000000..74cd5fff1bb--- /dev/null+++ b/packages/twenty-server/src/engine/core-modules/tool/tools/http-tool/constants/http-tool-timeout-ms.constant.ts@@ -0,0 +1 @@+export const HTTP_TOOL_TIMEOUT_MS = 30_000;diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/http-tool/http-tool.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/http-tool/http-tool.tsindex 4e0794fbadf..ca5c7653749 100644--- a/packages/twenty-server/src/engine/core-modules/tool/tools/http-tool/http-tool.ts+++ b/packages/twenty-server/src/engine/core-modules/tool/tools/http-tool/http-tool.ts@@ -5,6 +5,8 @@ import { isDefined } from 'twenty-shared/utils';import { parseDataFromContentType } from 'twenty-shared/workflow';import { SecureHttpClientService } from 'src/engine/core-modules/secure-http-client/secure-http-client.service';+import { HTTP_TOOL_MAX_PAYLOAD_SIZE_BYTES } from 'src/engine/core-modules/tool/tools/http-tool/constants/http-tool-max-payload-size-bytes.constant';+import { HTTP_TOOL_TIMEOUT_MS } from 'src/engine/core-modules/tool/tools/http-tool/constants/http-tool-timeout-ms.constant';import { HttpRequestInputZodSchema } from 'src/engine/core-modules/tool/tools/http-tool/http-tool.schema';import { type HttpRequestInput } from 'src/engine/core-modules/tool/tools/http-tool/types/http-request-input.type';import { type ToolInput } from 'src/engine/core-modules/tool/types/tool-input.type';@@ -29,12 +31,16 @@ export class HttpTool implements Tool {const { url, method, headers, body } = parameters as HttpRequestInput;const headersCopy = { ...headers };const isMethodForBody = ['POST', 'PUT', 'PATCH'].includes(method);+ const timeoutSignal = AbortSignal.timeout(HTTP_TOOL_TIMEOUT_MS);try {const axiosConfig: AxiosRequestConfig = {url,method: method,headers: headersCopy,+ signal: timeoutSignal,+ maxContentLength: HTTP_TOOL_MAX_PAYLOAD_SIZE_BYTES,+ maxBodyLength: HTTP_TOOL_MAX_PAYLOAD_SIZE_BYTES,};if (isMethodForBody && body) {@@ -66,10 +72,14 @@ export class HttpTool implements Tool {};} catch (error) {if (isAxiosError(error)) {+ const errorMessage = timeoutSignal.aborted+ ? `Request timed out after ${HTTP_TOOL_TIMEOUT_MS / 1_000}s`+ : error.message;+return {success: false,message: `HTTP ${method} request to ${url} failed`,- error: error.response?.data || error.message || 'HTTP request failed',+ error: error.response?.data || errorMessage || 'HTTP request failed',status: error.response?.status,statusText: error.response?.statusText,headers: error.response?.headers as