From 4d6a4566b752d586bec4f76d9b30de8f84839398 Mon Sep 17 00:00:00 2001 From: Emir Karabeg Date: Tue, 15 Apr 2025 13:46:09 -0700 Subject: [PATCH] fix(webhooks): long-process webhooks --- sim/app/api/webhooks/trigger/[path]/route.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sim/app/api/webhooks/trigger/[path]/route.ts b/sim/app/api/webhooks/trigger/[path]/route.ts index 444011859f..ab16d2c91a 100644 --- a/sim/app/api/webhooks/trigger/[path]/route.ts +++ b/sim/app/api/webhooks/trigger/[path]/route.ts @@ -314,6 +314,13 @@ export async function POST( } })(); + // Store reference to processing task to prevent garbage collection + const taskId = `${requestId}:${Date.now()}`; + activeProcessingTasks.set(taskId, processingPromise.finally(() => { + logger.info(`[${requestId}] Processing complete, removing from active tasks`); + activeProcessingTasks.delete(taskId); + })); + // Race processing against timeout to ensure fast response return Promise.race([timeoutPromise, processingPromise]); }