Kimi K3.1 Pro · Heavy

sms-workflow-reminder-retry-count-tracking-cal-com

cal.com · TypeScript · S · 30–99 lines · 3 files

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Haiku 5.5.

Gold bugs found
3 of 5
Comments published
4
Comments matching a bug
3
Comments not matching
1
Cost of this PR
$0.989

Published comments (4)

mediumbugpackages/features/ee/workflows/api/scheduleSMSReminders.ts:38-42

Retry cleanup deletes non-SMS reminders before their scheduled date — Future-dated EMAIL and WHATSAPP reminders can be permanently removed by the SMS cron. Apply `method: WorkflowMethods.SMS` to both `OR` branches so the `retryCount > 1` cleanup cannot match other delivery methods.

mediumbugpackages/features/ee/workflows/api/scheduleSMSReminders.ts:178-186

SMS reminders without recipients never increment retryCount — When `smsReminderNumber = null`, an `SMS_ATTENDEE` reminder skips the `message && sendTo` branch, leaving `retryCount` at 0 and causing reprocessing until its scheduled date. Increment `retryCount` on the no-recipient path so undeliverable reminders can be retired.

mediumbugpackages/features/ee/workflows/api/scheduleSMSReminders.ts:179-196

Concurrent SMS failures can undercount retries and exceed the retry limit — Concurrent scheduler runs can record several failed attempts as one, letting delivery attempts continue beyond the retry limit. Replace `reminder.retryCount + 1` with an atomic database increment in both failure paths instead of using the stale `findMany` snapshot.

mediumbugpackages/features/ee/workflows/api/scheduleSMSReminders.ts:190-197

Retry-count update failures can abort SMS reminder processing — A failure from `prisma.workflowReminder.update` inside the error handler escapes and skips the remaining `unscheduledReminders`, whether the row was removed by cleanup or the update otherwise failed. Catch persistence errors separately and tolerate missing rows so the original scheduling error cannot abort the run.

Gold bugs found (3)

mediumretryCount is set to reminder.retryCount + 1 from a value read at the start of the run instead of an atomic increment, so overlapping runs can lose increments.
highThe deleteMany OR clause applies retryCount > 1 without the SMS method filter, so the SMS cron deletes any workflow reminder (email, WhatsApp) with retryCount above 1.
mediumThe retry-count update inside the catch block is not guarded, so if it throws (for example the reminder was deleted concurrently) the error escapes the loop and the cron run fails, skipping the remaining reminders.

Gold bugs missed (2)

criticalClaims transient errors increment retryCount, so two runs during an outage delete the whole pending SMS reminder queue.
highSMS-sending locks are counted as failed scheduling attempts: scheduleSMS returns undefined for locked users/teams, retryCount is incremented, and after two cron runs the retryCount > 1 cleanup deletes future reminders even if sending is later unlocked.