Skip to content

Commit 18b9ec9

Browse files
committed
improvement(redis-cleanup): schedule, async workflow, hitl bae64 cache cleanup
1 parent 674dd8d commit 18b9ec9

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

apps/sim/background/schedule-execution.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
import { preprocessExecution } from '@/lib/execution/preprocessing'
2222
import { LoggingSession } from '@/lib/logs/execution/logging-session'
2323
import { buildTraceSpans } from '@/lib/logs/execution/trace-spans/trace-spans'
24+
import { cleanupExecutionBase64Cache } from '@/lib/uploads/utils/user-file-base64.server'
2425
import {
2526
executeWorkflowCore,
2627
wasExecutionFinalizedByCore,
@@ -348,6 +349,13 @@ async function runWorkflowExecution({
348349
})
349350

350351
throw error
352+
} finally {
353+
void cleanupExecutionBase64Cache(executionId).catch((cleanupError) => {
354+
logger.warn(`[${requestId}] Failed to cleanup base64 cache`, {
355+
executionId,
356+
error: toError(cleanupError).message,
357+
})
358+
})
351359
}
352360
}
353361

apps/sim/background/workflow-execution.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { createTimeoutAbortController, getTimeoutErrorMessage } from '@/lib/core
77
import { preprocessExecution } from '@/lib/execution/preprocessing'
88
import { LoggingSession } from '@/lib/logs/execution/logging-session'
99
import { buildTraceSpans } from '@/lib/logs/execution/trace-spans/trace-spans'
10+
import { cleanupExecutionBase64Cache } from '@/lib/uploads/utils/user-file-base64.server'
1011
import {
1112
executeWorkflowCore,
1213
wasExecutionFinalizedByCore,
@@ -196,6 +197,13 @@ export async function executeWorkflowJob(payload: WorkflowExecutionPayload) {
196197
})
197198

198199
throw error
200+
} finally {
201+
void cleanupExecutionBase64Cache(executionId).catch((cleanupError) => {
202+
logger.warn(`[${requestId}] Failed to cleanup base64 cache`, {
203+
executionId,
204+
error: toError(cleanupError).message,
205+
})
206+
})
199207
}
200208
})
201209
}

apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import { compactBlockLogs, compactExecutionPayload } from '@/lib/execution/payloads/serializer'
1717
import { preprocessExecution } from '@/lib/execution/preprocessing'
1818
import { LoggingSession } from '@/lib/logs/execution/logging-session'
19+
import { cleanupExecutionBase64Cache } from '@/lib/uploads/utils/user-file-base64.server'
1920
import { executeWorkflowCore } from '@/lib/workflows/executor/execution-core'
2021
import type { ExecutionEvent } from '@/lib/workflows/executor/execution-events'
2122
import { ExecutionSnapshot } from '@/executor/execution/snapshot'
@@ -1363,6 +1364,12 @@ export class PauseResumeManager {
13631364
})
13641365
})
13651366
}
1367+
void cleanupExecutionBase64Cache(resumeExecutionId).catch((error) => {
1368+
logger.warn('Failed to cleanup base64 cache for resume execution', {
1369+
resumeExecutionId,
1370+
error: toError(error).message,
1371+
})
1372+
})
13661373
}
13671374

13681375
if (executionError || !result) {

0 commit comments

Comments
 (0)