Skip to content

Commit 0d5e813

Browse files
committed
remove backoff logic
1 parent 4cca86e commit 0d5e813

3 files changed

Lines changed: 7 additions & 24 deletions

File tree

apps/sim/background/schedule-execution.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import {
3939
SCHEDULE_INFRA_RETRY_BASE_MS,
4040
SCHEDULE_INFRA_RETRY_MAX_ATTEMPTS,
4141
SCHEDULE_INFRA_RETRY_MAX_MS,
42-
SCHEDULE_USAGE_LIMIT_BACKOFF_MS,
4342
} from '@/lib/workflows/schedules/execution-limits'
4443
import {
4544
type BlockState,
@@ -794,20 +793,16 @@ export async function executeScheduleJob(payload: ScheduleExecutionPayload) {
794793

795794
case 402: {
796795
/**
797-
* Usage limits are a billing state, not a broken workflow, and only clear
798-
* on billing-period rollover or upgrade. Back off to at most the usage-limit
799-
* cadence (never faster than the schedule's own cadence) so an over-limit
800-
* schedule stops re-running every tick, and count each hit toward the shared
801-
* auto-disable threshold so an abandoned over-limit schedule eventually stops.
796+
* Usage limits are a billing state, not a broken workflow, but they only
797+
* clear on billing-period rollover or upgrade. Keep retrying at the normal
798+
* cadence, but count each hit toward the shared auto-disable threshold so an
799+
* abandoned over-limit schedule eventually stops instead of running forever.
802800
* A successful run resets failedCount, so transient overages self-heal.
803801
*/
804-
const cronNextRunAt = await calculateNextRunFromDeployment(payload, requestId)
805-
const backoffRunAt = new Date(now.getTime() + SCHEDULE_USAGE_LIMIT_BACKOFF_MS)
806802
const nextRunAt =
807-
cronNextRunAt && cronNextRunAt.getTime() > backoffRunAt.getTime()
808-
? cronNextRunAt
809-
: backoffRunAt
810-
logger.warn(`[${requestId}] Usage limit exceeded, backing off scheduled run`, {
803+
(await calculateNextRunFromDeployment(payload, requestId)) ??
804+
new Date(now.getTime() + 60 * 60 * 1000)
805+
logger.warn(`[${requestId}] Usage limit exceeded, counting as failed run`, {
811806
scheduleId: payload.scheduleId,
812807
nextRunAt: nextRunAt.toISOString(),
813808
})

apps/sim/lib/core/config/env.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ export const env = createEnv({
204204
SCHEDULE_INFRA_RETRY_BASE_MS: z.string().optional().default('60000'),
205205
SCHEDULE_INFRA_RETRY_MAX_MS: z.string().optional().default('300000'),
206206
SCHEDULE_INFRA_RETRY_MAX_ATTEMPTS: z.string().optional().default('10'),
207-
SCHEDULE_USAGE_LIMIT_BACKOFF_MS: z.string().optional().default('3600000'), // Min gap between retries while over usage limit (default 1h)
208207

209208
// Cloud Storage - AWS S3
210209
AWS_REGION: z.string().optional(), // AWS region for S3 buckets

apps/sim/lib/workflows/schedules/execution-limits.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,3 @@ export const SCHEDULE_INFRA_RETRY_MAX_ATTEMPTS = envNumber(
4040
integer: true,
4141
}
4242
)
43-
44-
/**
45-
* Minimum delay before a schedule retries after hitting a usage limit (402).
46-
* Usage limits only clear on billing-period rollover or upgrade, so over-limit
47-
* schedules back off to (at most) this cadence instead of re-running every tick.
48-
*/
49-
export const SCHEDULE_USAGE_LIMIT_BACKOFF_MS = envNumber(
50-
env.SCHEDULE_USAGE_LIMIT_BACKOFF_MS,
51-
60 * 60_000,
52-
{ min: 1, integer: true }
53-
)

0 commit comments

Comments
 (0)