GLM-5.3 Flash · 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 Opus 5.5.

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

Published comments (3)

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

SMS sending lock inflates retryCount and permanently deletes reminders — Attendees silently lose reminders: the transient monthly-limit lock in twilioProvider.ts makes `scheduleSMS` return undefined, so two locked cron runs push `retryCount` past 1 and the next `deleteMany` permanently deletes the reminder. Don't treat a locked send as a scheduling failure.

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

Unguarded update in catch block can throw and skip remaining reminders — If the update throws (e.g. `P2025` when an overlapping cron run already deleted the reminder), the error escapes the handler and skips all remaining reminders. Wrap `prisma.workflowReminder.update` in its own try/catch so the loop continues.

mediumperformancepackages/prisma/schema.prisma:1000

retryCount added without an index for the cleanup query predicate — The cron's `deleteMany` in scheduleSMSReminders.ts filters on `retryCount > 1` every run, and the existing `[method, scheduled, scheduledDate]` index doesn't cover it, so each invocation scans the table. Add an index on `retryCount` (or a partial one).

Gold bugs found (2)

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 (4)

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