From 4df319c32157d9627c42751480a4afa5e155a3e7 Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Mon, 2 Feb 2026 01:18:45 -0800 Subject: [PATCH] fix(cleanup-cron): stale execution cleanup integer overflow --- apps/sim/app/api/cron/cleanup-stale-executions/route.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/sim/app/api/cron/cleanup-stale-executions/route.ts b/apps/sim/app/api/cron/cleanup-stale-executions/route.ts index 5c4ba7921..2b0859143 100644 --- a/apps/sim/app/api/cron/cleanup-stale-executions/route.ts +++ b/apps/sim/app/api/cron/cleanup-stale-executions/route.ts @@ -8,6 +8,7 @@ import { verifyCronAuth } from '@/lib/auth/internal' const logger = createLogger('CleanupStaleExecutions') const STALE_THRESHOLD_MINUTES = 30 +const MAX_INT32 = 2_147_483_647 export async function GET(request: NextRequest) { try { @@ -45,13 +46,14 @@ export async function GET(request: NextRequest) { try { const staleDurationMs = Date.now() - new Date(execution.startedAt).getTime() const staleDurationMinutes = Math.round(staleDurationMs / 60000) + const totalDurationMs = Math.min(staleDurationMs, MAX_INT32) await db .update(workflowExecutionLogs) .set({ status: 'failed', endedAt: new Date(), - totalDurationMs: staleDurationMs, + totalDurationMs, executionData: sql`jsonb_set( COALESCE(execution_data, '{}'::jsonb), ARRAY['error'],