Skip to content

Commit 7940e30

Browse files
waleedlatif1claude
andcommitted
fix(data-drains): isolate per-org enterprise check failures in dispatcher
A throw from isOrganizationOnEnterprisePlan (Stripe outage, DB timeout) for one org used to propagate out of the for-loop and abort the whole dispatch batch. Wrap the check in try-catch so a single bad lookup just skips that drain — the next cron tick retries it. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 5c67e99 commit 7940e30

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

apps/sim/lib/data-drains/dispatcher.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,21 @@ export async function dispatchDueDrains(now: Date = new Date()): Promise<{
103103
let skipped = 0
104104

105105
for (const candidate of candidates) {
106-
if (!(await isEnterprise(candidate.organizationId))) {
106+
let enterprise: boolean
107+
try {
108+
enterprise = await isEnterprise(candidate.organizationId)
109+
} catch (error) {
110+
// A billing-API failure for one org must not abort the whole batch —
111+
// skip this drain and let the next cron tick retry it.
112+
logger.warn('Enterprise check failed; skipping drain', {
113+
drainId: candidate.id,
114+
organizationId: candidate.organizationId,
115+
error,
116+
})
117+
skipped++
118+
continue
119+
}
120+
if (!enterprise) {
107121
skipped++
108122
continue
109123
}

0 commit comments

Comments
 (0)