Skip to content

Commit 5ab2db2

Browse files
fix(cron): derive async job retention cutoffs from one clock read
1 parent 158214a commit 5ab2db2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • apps/sim/app/api/cron/cleanup-stale-executions

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,10 @@ export const GET = withRouteHandler(async (request: NextRequest) => {
504504
})
505505
}
506506

507-
const retentionThreshold = new Date(Date.now() - JOB_RETENTION_HOURS * 60 * 60 * 1000)
507+
const retentionNow = Date.now()
508+
const retentionThreshold = new Date(retentionNow - JOB_RETENTION_HOURS * 60 * 60 * 1000)
508509
const irrecoverableCarrierRetentionThreshold = new Date(
509-
Date.now() - SCHEDULE_CARRIER_IRRECOVERABLE_RETENTION_HOURS * 60 * 60 * 1000
510+
retentionNow - SCHEDULE_CARRIER_IRRECOVERABLE_RETENTION_HOURS * 60 * 60 * 1000
510511
)
511512
let asyncJobsDeleted = 0
512513

0 commit comments

Comments
 (0)