Skip to content

Commit 81bcdf2

Browse files
improvement(schedules): retries, concurrency limits (#4755)
* improvement(schedu les): retries, concurrency limits * improvement(schedules): remove stale generated migration Drop the pre-merge generated 0213 migration so it can be regenerated after syncing with staging. Co-authored-by: Cursor <cursoragent@cursor.com> * address comments * fix pinned version for lru cache * retryable errs cleanup --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 90c9590 commit 81bcdf2

28 files changed

Lines changed: 19590 additions & 396 deletions

File tree

apps/sim/app/api/environment/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AuditAction, AuditResourceType, recordAudit } from '@sim/audit'
22
import { db } from '@sim/db'
33
import { environment } from '@sim/db/schema'
44
import { createLogger } from '@sim/logger'
5+
import { toError } from '@sim/utils/errors'
56
import { generateId } from '@sim/utils/id'
67
import { eq } from 'drizzle-orm'
78
import { type NextRequest, NextResponse } from 'next/server'
@@ -136,8 +137,8 @@ export const GET = withRouteHandler(async (request: Request) => {
136137
>
137138

138139
return NextResponse.json({ data: decryptedVariables }, { status: 200 })
139-
} catch (error: any) {
140+
} catch (error) {
140141
logger.error(`[${requestId}] Environment fetch error`, error)
141-
return NextResponse.json({ error: error.message }, { status: 500 })
142+
return NextResponse.json({ error: toError(error).message }, { status: 500 })
142143
}
143144
})

apps/sim/app/api/schedules/[id]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export const PUT = withRouteHandler(
135135

136136
await db
137137
.update(workflowSchedule)
138-
.set({ status: 'disabled', nextRunAt: null, updatedAt: new Date() })
138+
.set({ status: 'disabled', nextRunAt: null, lastQueuedAt: null, updatedAt: new Date() })
139139
.where(and(eq(workflowSchedule.id, scheduleId), isNull(workflowSchedule.archivedAt)))
140140

141141
logger.info(`[${requestId}] Disabled schedule: ${scheduleId}`)
@@ -220,7 +220,7 @@ export const PUT = withRouteHandler(
220220

221221
await db
222222
.update(workflowSchedule)
223-
.set({ status: 'active', failedCount: 0, updatedAt: now, nextRunAt })
223+
.set({ status: 'active', failedCount: 0, infraRetryCount: 0, updatedAt: now, nextRunAt })
224224
.where(and(eq(workflowSchedule.id, scheduleId), isNull(workflowSchedule.archivedAt)))
225225

226226
logger.info(`[${requestId}] Reactivated schedule: ${scheduleId}`)

0 commit comments

Comments
 (0)