GLM-5.3 Flash · 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
2 of 6
Comments published
3
Comments matching a bug
2
Comments not matching
1
Cost of this PR
$0.086

Published comments (3)

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

Unindexed retryCount disjunct forces full scan of WorkflowReminder on every cron run — The OR branch filters on `retryCount`, which has no index on `WorkflowReminder`, so every cron run degrades to a full scan instead of using the `method`/`scheduledDate` composite index. Add an index on `retryCount` or scope the branch with the same `method` filter.

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

Non-atomic retryCount increment loses updates across overlapping cron runs — Overlapping cron runs read the same `retryCount` snapshot and both write value+1, losing increments, so a repeatedly failing reminder can stay below the cleanup threshold and retry forever. Use an atomic `retryCount: { increment: 1 }` in the update data.

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

Catch-block retryCount update can throw and abort remaining reminders — The update inside the catch can itself throw — e.g. `P2025` when a reminder was concurrently deleted — aborting the loop so remaining reminders are skipped and the cron request fails. Wrap it in its own try/catch or use `updateMany`, which doesn't throw on missing rows.

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

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