GLM-5.3 · Balanced

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

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

The normal review, with one generalist agent. Judge: Claude Haiku 5.5.

Gold bugs found
3 of 5
Comments published
3
Comments matching a bug
3
Comments not matching
0
Cost of this PR
$0.512

Published comments (3)

highbugpackages/features/ee/workflows/api/scheduleSMSReminders.ts:189-197

Unprotected prisma update in catch block aborts the reminder loop and 200 response — A row deleted mid-run by `deleteScheduledSMSReminder` (or a transient DB error) makes this update throw P2025, escaping the loop, skipping remaining reminders, and losing the 200 response. Wrap the catch-block `prisma.workflowReminder.update` in its own try/catch.

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

Transient SMS failures counted as retries, deleting reminders that could still be sent — Both the `else` branch and `catch` increment `retryCount` even when `twilio.scheduleSMS` failed transiently — `smsLockState` LOCKED or a rate limit — so `deleteMany` irreversibly purges reminders that could still be sent. Increment only for non-retryable errors like invalid phone numbers.

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

`retryCount` read-modify-write loses updates on overlapping cron runs — Overlapping cron runs both read the same snapshot and write the same `retryCount: reminder.retryCount + 1`, undercounting failed attempts and letting duplicate SMS go out before `deleteMany` purges the reminder. Use atomic `retryCount: { increment: 1 }` in both update calls.

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.
criticalClaims transient errors increment retryCount, so two runs during an outage delete the whole pending SMS reminder queue.

Gold bugs missed (2)

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