From 18b9ec9e3a9fd30da0c0ee95a18e06ed3714a95c Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Sun, 17 May 2026 13:05:09 -0700 Subject: [PATCH 1/2] improvement(redis-cleanup): schedule, async workflow, hitl bae64 cache cleanup --- apps/sim/background/schedule-execution.ts | 8 ++++++++ apps/sim/background/workflow-execution.ts | 8 ++++++++ .../lib/workflows/executor/human-in-the-loop-manager.ts | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/apps/sim/background/schedule-execution.ts b/apps/sim/background/schedule-execution.ts index 7da80cab40f..098695559de 100644 --- a/apps/sim/background/schedule-execution.ts +++ b/apps/sim/background/schedule-execution.ts @@ -21,6 +21,7 @@ import { import { preprocessExecution } from '@/lib/execution/preprocessing' import { LoggingSession } from '@/lib/logs/execution/logging-session' import { buildTraceSpans } from '@/lib/logs/execution/trace-spans/trace-spans' +import { cleanupExecutionBase64Cache } from '@/lib/uploads/utils/user-file-base64.server' import { executeWorkflowCore, wasExecutionFinalizedByCore, @@ -348,6 +349,13 @@ async function runWorkflowExecution({ }) throw error + } finally { + void cleanupExecutionBase64Cache(executionId).catch((cleanupError) => { + logger.warn(`[${requestId}] Failed to cleanup base64 cache`, { + executionId, + error: toError(cleanupError).message, + }) + }) } } diff --git a/apps/sim/background/workflow-execution.ts b/apps/sim/background/workflow-execution.ts index 06d4e34180b..33844df3d02 100644 --- a/apps/sim/background/workflow-execution.ts +++ b/apps/sim/background/workflow-execution.ts @@ -7,6 +7,7 @@ import { createTimeoutAbortController, getTimeoutErrorMessage } from '@/lib/core import { preprocessExecution } from '@/lib/execution/preprocessing' import { LoggingSession } from '@/lib/logs/execution/logging-session' import { buildTraceSpans } from '@/lib/logs/execution/trace-spans/trace-spans' +import { cleanupExecutionBase64Cache } from '@/lib/uploads/utils/user-file-base64.server' import { executeWorkflowCore, wasExecutionFinalizedByCore, @@ -196,6 +197,13 @@ export async function executeWorkflowJob(payload: WorkflowExecutionPayload) { }) throw error + } finally { + void cleanupExecutionBase64Cache(executionId).catch((cleanupError) => { + logger.warn(`[${requestId}] Failed to cleanup base64 cache`, { + executionId, + error: toError(cleanupError).message, + }) + }) } }) } diff --git a/apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts b/apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts index 96054e5108e..563f994bd02 100644 --- a/apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts +++ b/apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts @@ -16,6 +16,7 @@ import { import { compactBlockLogs, compactExecutionPayload } from '@/lib/execution/payloads/serializer' import { preprocessExecution } from '@/lib/execution/preprocessing' import { LoggingSession } from '@/lib/logs/execution/logging-session' +import { cleanupExecutionBase64Cache } from '@/lib/uploads/utils/user-file-base64.server' import { executeWorkflowCore } from '@/lib/workflows/executor/execution-core' import type { ExecutionEvent } from '@/lib/workflows/executor/execution-events' import { ExecutionSnapshot } from '@/executor/execution/snapshot' @@ -1363,6 +1364,12 @@ export class PauseResumeManager { }) }) } + void cleanupExecutionBase64Cache(resumeExecutionId).catch((error) => { + logger.warn('Failed to cleanup base64 cache for resume execution', { + resumeExecutionId, + error: toError(error).message, + }) + }) } if (executionError || !result) { From 3a4d277d662ba35b9afe51a27b1d328dd29e8b9c Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Sun, 17 May 2026 15:00:12 -0700 Subject: [PATCH 2/2] address comments --- apps/sim/background/schedule-execution.ts | 7 +------ apps/sim/background/workflow-execution.ts | 7 +------ .../lib/workflows/executor/human-in-the-loop-manager.ts | 7 +------ 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/apps/sim/background/schedule-execution.ts b/apps/sim/background/schedule-execution.ts index 098695559de..5844dd3164d 100644 --- a/apps/sim/background/schedule-execution.ts +++ b/apps/sim/background/schedule-execution.ts @@ -350,12 +350,7 @@ async function runWorkflowExecution({ throw error } finally { - void cleanupExecutionBase64Cache(executionId).catch((cleanupError) => { - logger.warn(`[${requestId}] Failed to cleanup base64 cache`, { - executionId, - error: toError(cleanupError).message, - }) - }) + void cleanupExecutionBase64Cache(executionId) } } diff --git a/apps/sim/background/workflow-execution.ts b/apps/sim/background/workflow-execution.ts index 33844df3d02..88b355d7d58 100644 --- a/apps/sim/background/workflow-execution.ts +++ b/apps/sim/background/workflow-execution.ts @@ -198,12 +198,7 @@ export async function executeWorkflowJob(payload: WorkflowExecutionPayload) { throw error } finally { - void cleanupExecutionBase64Cache(executionId).catch((cleanupError) => { - logger.warn(`[${requestId}] Failed to cleanup base64 cache`, { - executionId, - error: toError(cleanupError).message, - }) - }) + void cleanupExecutionBase64Cache(executionId) } }) } diff --git a/apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts b/apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts index 563f994bd02..74bec36df22 100644 --- a/apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts +++ b/apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts @@ -1364,12 +1364,7 @@ export class PauseResumeManager { }) }) } - void cleanupExecutionBase64Cache(resumeExecutionId).catch((error) => { - logger.warn('Failed to cleanup base64 cache for resume execution', { - resumeExecutionId, - error: toError(error).message, - }) - }) + void cleanupExecutionBase64Cache(resumeExecutionId) } if (executionError || !result) {