Skip to content

Commit 51a031a

Browse files
committed
consolidate consts
1 parent a65bae9 commit 51a031a

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/schedule-info/schedule-info.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Badge } from '@/components/emcn'
33
import { parseCronToHumanReadable } from '@/lib/workflows/schedules/utils'
44
import { useRedeployWorkflowSchedule, useScheduleQuery } from '@/hooks/queries/schedules'
55
import { useSubBlockStore } from '@/stores/workflows/subblock/store'
6+
import { MAX_CONSECUTIVE_FAILURES } from '@/triggers/constants'
67

78
interface ScheduleInfoProps {
89
blockId: string
@@ -46,7 +47,7 @@ export function ScheduleInfo({ blockId, isPreview = false }: ScheduleInfoProps)
4647
{(failedCount > 0 || isDisabled) && (
4748
<div className='space-y-1'>
4849
<div className='flex flex-wrap items-center gap-2'>
49-
{failedCount >= 100 && isDisabled ? (
50+
{failedCount >= MAX_CONSECUTIVE_FAILURES && isDisabled ? (
5051
<Badge
5152
variant='outline'
5253
className='cursor-pointer'
@@ -70,9 +71,14 @@ export function ScheduleInfo({ blockId, isPreview = false }: ScheduleInfoProps)
7071
</Badge>
7172
) : null}
7273
</div>
73-
{failedCount >= 100 && isDisabled && (
74+
{failedCount >= MAX_CONSECUTIVE_FAILURES && isDisabled && (
7475
<p className='text-[12px] text-[var(--text-tertiary)]'>
75-
Disabled after 100 consecutive failures
76+
Disabled after {MAX_CONSECUTIVE_FAILURES} consecutive failures
77+
</p>
78+
)}
79+
{redeployMutation.isError && (
80+
<p className='text-[12px] text-[var(--text-error)]'>
81+
Failed to redeploy. Please try again.
7682
</p>
7783
)}
7884
</div>

apps/sim/background/schedule-execution.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ import { type ExecutionMetadata, ExecutionSnapshot } from '@/executor/execution/
2727
import type { ExecutionResult } from '@/executor/types'
2828
import { createEnvVarPattern } from '@/executor/utils/reference-validation'
2929
import { mergeSubblockState } from '@/stores/workflows/server-utils'
30+
import { MAX_CONSECUTIVE_FAILURES } from '@/triggers/constants'
3031

3132
const logger = createLogger('TriggerScheduleExecution')
3233

33-
const MAX_CONSECUTIVE_FAILURES = 100
34-
3534
type WorkflowRecord = typeof workflow.$inferSelect
3635
type WorkflowScheduleUpdate = Partial<typeof workflowSchedule.$inferInsert>
3736
type ExecutionCoreResult = Awaited<ReturnType<typeof executeWorkflowCore>>

apps/sim/lib/webhooks/gmail-polling-service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import { createLogger } from '@/lib/logs/console/logger'
88
import { getOAuthToken, refreshAccessTokenIfNeeded } from '@/app/api/auth/oauth/utils'
99
import type { GmailAttachment } from '@/tools/gmail/types'
1010
import { downloadAttachments, extractAttachmentInfo } from '@/tools/gmail/utils'
11+
import { MAX_CONSECUTIVE_FAILURES } from '@/triggers/constants'
1112

1213
const logger = createLogger('GmailPollingService')
1314

14-
const MAX_CONSECUTIVE_FAILURES = 100
15-
1615
interface GmailWebhookConfig {
1716
labelIds: string[]
1817
labelFilterBehavior: 'INCLUDE' | 'EXCLUDE'

apps/sim/lib/webhooks/outlook-polling-service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import { pollingIdempotency } from '@/lib/core/idempotency'
77
import { getBaseUrl } from '@/lib/core/utils/urls'
88
import { createLogger } from '@/lib/logs/console/logger'
99
import { getOAuthToken, refreshAccessTokenIfNeeded } from '@/app/api/auth/oauth/utils'
10+
import { MAX_CONSECUTIVE_FAILURES } from '@/triggers/constants'
1011

1112
const logger = createLogger('OutlookPollingService')
1213

13-
const MAX_CONSECUTIVE_FAILURES = 100
14-
1514
async function markWebhookFailed(webhookId: string) {
1615
try {
1716
const result = await db

apps/sim/lib/webhooks/rss-polling-service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import { pollingIdempotency } from '@/lib/core/idempotency/service'
77
import { createPinnedUrl, validateUrlWithDNS } from '@/lib/core/security/input-validation'
88
import { getBaseUrl } from '@/lib/core/utils/urls'
99
import { createLogger } from '@/lib/logs/console/logger'
10+
import { MAX_CONSECUTIVE_FAILURES } from '@/triggers/constants'
1011

1112
const logger = createLogger('RssPollingService')
12-
13-
const MAX_CONSECUTIVE_FAILURES = 100
1413
const MAX_GUIDS_TO_TRACK = 100 // Track recent guids to prevent duplicates
1514

1615
interface RssWebhookConfig {

apps/sim/triggers/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,9 @@ export const TRIGGER_RUNTIME_SUBBLOCK_IDS: string[] = [
4040
'testUrl',
4141
'testUrlExpiresAt',
4242
]
43+
44+
/**
45+
* Maximum number of consecutive failures before a trigger (schedule/webhook) is auto-disabled.
46+
* This prevents runaway errors from continuously executing failing workflows.
47+
*/
48+
export const MAX_CONSECUTIVE_FAILURES = 100

0 commit comments

Comments
 (0)