Skip to content

Commit b738550

Browse files
fix(cleanup-cron): stale execution cleanup integer overflow (#3113)
1 parent c6357f7 commit b738550

File tree

1 file changed

+3
-1
lines changed
  • apps/sim/app/api/cron/cleanup-stale-executions

1 file changed

+3
-1
lines changed

apps/sim/app/api/cron/cleanup-stale-executions/route.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { verifyCronAuth } from '@/lib/auth/internal'
88
const logger = createLogger('CleanupStaleExecutions')
99

1010
const STALE_THRESHOLD_MINUTES = 30
11+
const MAX_INT32 = 2_147_483_647
1112

1213
export async function GET(request: NextRequest) {
1314
try {
@@ -45,13 +46,14 @@ export async function GET(request: NextRequest) {
4546
try {
4647
const staleDurationMs = Date.now() - new Date(execution.startedAt).getTime()
4748
const staleDurationMinutes = Math.round(staleDurationMs / 60000)
49+
const totalDurationMs = Math.min(staleDurationMs, MAX_INT32)
4850

4951
await db
5052
.update(workflowExecutionLogs)
5153
.set({
5254
status: 'failed',
5355
endedAt: new Date(),
54-
totalDurationMs: staleDurationMs,
56+
totalDurationMs,
5557
executionData: sql`jsonb_set(
5658
COALESCE(execution_data, '{}'::jsonb),
5759
ARRAY['error'],

0 commit comments

Comments
 (0)