Amazon Ergo 1.0 · 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 Opus 5.5.

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

Published comments (4)

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

SMS-locked cron runs count as failed retries, deleting valid reminders — SMS-locked accounts can permanently lose valid booking reminders: this `else` branch increments `retryCount` without any delivery attempt, triggering the `retryCount > 1` deletion. Skip the increment when `twilio.scheduleSMS` returns `undefined` because `isLockedForSMSSending` is set; count only attempted sends that fail.

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

retryCount cleanup can delete successfully scheduled SMS reminders — Overlapping runs can leave a scheduled reminder with `retryCount > 1`; deleting it strands the live Twilio message where cancellation flows cannot find it. Add `scheduled: false` to the cleanup filter so only unsent reminders are purged.

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

Concurrent cron runs can lose retryCount increments — Overlapping cron runs can both write the same stale `reminder.retryCount + 1`, losing a failure and allowing attempts beyond the intended limit. Use atomic `retryCount: { increment: 1 }` updates in both failure paths.

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

Unguarded retry-count update in catch aborts remaining reminders — A deleted reminder (`P2025`) or transient DB error can make this `prisma.workflowReminder.update(...)` throw, aborting the loop and skipping every remaining reminder. Wrap both retry-count updates in their own try/catch, or use `updateMany` so missing rows are a no-op.

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

Gold bugs missed (3)

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.
criticalClaims transient errors increment retryCount, so two runs during an outage delete the whole pending SMS reminder queue.
mediumscheduleWhatsappReminders never increments retryCount on Twilio failure, so failing WhatsApp reminders are retried on every cron run and never reach the retryCount > 1 cleanup added for SMS.