MiniMax M3 · 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
2 of 5
Comments published
2
Comments matching a bug
2
Comments not matching
0
Cost of this PR
$0.147

Published comments (2)

mediumbugpackages/features/ee/workflows/api/scheduleSMSReminders.ts:28-45

scheduleSMSReminders deleteMany OR clause is not scoped to SMS method — Without an outer `method: WorkflowMethods.SMS` filter on `deleteMany`, the second OR branch (`retryCount > 1`) would silently purge EMAIL or WHATSAPP reminders if any future code path ever sets that field on them. Wrap both OR branches in an SMS filter so the deletion scope matches the handler.

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

retryCount update is a lost-update race between concurrent cron workers — Two concurrent cron workers can each read `retryCount` as 0 and write 1, losing an increment and delaying the `deleteMany` gate at `retryCount > 1` by one cycle. Replace the JS read-then-write in `prisma.workflowReminder.update` with `retryCount: { increment: 1 }` so the write is atomic.

Gold bugs found (2)

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.

Gold bugs missed (3)

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.
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.