Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

fix(frontend): remove Automate operation timeout (#7082)

staticdevc3802ac1ef6f
diff --git a/frontend/editor/src/core/constants/automation.ts b/frontend/editor/src/core/constants/automation.ts
index 56fc7ee35f..a3fa1f5a82 100644
--- a/frontend/editor/src/core/constants/automation.ts
+++ b/frontend/editor/src/core/constants/automation.ts
@@ -3,9 +3,6 @@
*/
export const AUTOMATION_CONSTANTS = {
- // Timeouts
- OPERATION_TIMEOUT: 300000, // 5 minutes in milliseconds
-
// Default values
DEFAULT_TOOL_COUNT: 2,
MIN_TOOL_COUNT: 2,
diff --git a/frontend/editor/src/core/utils/automationExecutor.test.ts b/frontend/editor/src/core/utils/automationExecutor.test.ts
index 5cff7b2ab0..2eb2cd1d19 100644
--- a/frontend/editor/src/core/utils/automationExecutor.test.ts
+++ b/frontend/editor/src/core/utils/automationExecutor.test.ts
@@ -1,5 +1,19 @@
-import { describe, expect, test } from "vitest";
-import { processMultiFileResponse } from "@app/utils/automationExecutor";
+import { beforeEach, describe, expect, type Mock, test, vi } from "vitest";
+import apiClient from "@app/services/apiClient";
+import type { ToolRegistry } from "@app/data/toolsTaxonomy";
+import { ToolType } from "@app/hooks/tools/shared/useToolOperation";
+import {
+ executeToolOperation,
+ processMultiFileResponse,
+} from "@app/utils/automationExecutor";
+
+vi.mock("@app/services/apiClient", () => ({
+ default: {
+ post: vi.fn(),
+ },
+}));
+
+const mockedApiClient = vi.mocked(apiClient);
// Regression coverage for the automation-side mirror of the merge bug:
// non-canonical Content-Types previously misrouted a PDF into ZIP extraction
@@ -56,3 +70,39 @@ describe("processMultiFileResponse (automation execution)", () => {
expect(result[0].name).not.toMatch(/\.zip$/);
});
});
+
+describe("executeToolOperation (automation execution)", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ (mockedApiClient.post as Mock).mockResolvedValue({
+ data: new Blob([PDF_BYTES], { type: "application/pdf" }),
+ headers: { "content-type": "application/pdf" },
+ });
+ });
+
+ test("does not impose a client-side operation timeout", async () => {
+ const toolRegistry = {
+ compress: {
+ operationConfig: {
+ operationType: "compress",
+ toolType: ToolType.singleFile,
+ endpoint: "/api/v1/misc/compress-pdf",
+ defaultParameters: {},
+ buildFormData: (_parameters: unknown, file: File) => {
+ const formData = new FormData();
+ formData.append("fileInput", file);
+ return formData;
+ },
+ },
+ },
+ } as unknown as ToolRegistry;
+
+ await executeToolOperation("compress", {}, inputFiles, toolRegistry);
+
+ expect(mockedApiClient.post).toHaveBeenCalledWith(
+ "/api/v1/misc/compress-pdf",
+ expect.any(FormData),
+ { responseType: "blob" },
+ );
+ });
+});
diff --git a/frontend/editor/src/core/utils/automationExecutor.ts b/frontend/editor/src/core/utils/automationExecutor.ts
index f47778deda..7855bc25e7 100644
--- a/frontend/editor/src/core/utils/automationExecutor.ts
+++ b/frontend/editor/src/core/utils/automationExecutor.ts
@@ -65,7 +65,6 @@ const executeApiRequest = async (
): Promise<File[]> => {
const response = await apiClient.post(endpoint, formData, {
responseType: "blob",
- timeout: AUTOMATION_CONSTANTS.OPERATION_TIMEOUT,
});
return await processMultiFileResponse(
diff --git a/frontend/editor/src/core/utils/automationFileProcessor.ts b/frontend/editor/src/core/utils/automationFileProcessor.ts
index 5326abcdcc..6ff5a558be 100644
--- a/frontend/editor/src/core/utils/automationFileProcessor.ts
+++ b/frontend/editor/src/core/utils/automationFileProcessor.ts
@@ -97,7 +97,7 @@ export class AutomationFileProcessor {
try {
const response = await apiClient.post(endpoint, formData, {
responseType: options.responseType || "blob",
- timeout: options.timeout || AUTOMATION_CONSTANTS.OPERATION_TIMEOUT,
+ ...(options.timeout !== undefined ? { timeout: options.timeout } : {}),
});
if (response.status !== 200) {
@@ -143,7 +143,7 @@ export class AutomationFileProcessor {
try {
const response = await apiClient.post(endpoint, formData, {
responseType: options.responseType || "blob",
- timeout: options.timeout || AUTOMATION_CONSTANTS.OPERATION_TIMEOUT,
+ ...(options.timeout !== undefined ? { timeout: options.timeout } : {}),
});
if (response.status !== 200) {