DeepSeek V4.1 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 Haiku 5.5.

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

Published comments (4)

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

Locked SMS reminders are counted as failed retries — `twilio.scheduleSMS` returns `undefined` for a temporary SMS lock rather than an error, so a deliberate hold is recorded as a failed attempt. Since `deleteMany` then removes reminders above `retryCount` 1, locked accounts lose their SMS permanently; only increment when Twilio actually rejects the request, as in `twilioProvider.ts`.

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

Retry-count update in SMS reminder catch can abort remaining reminders — This `update` throws P2025 when the row is already gone, for example after `deleteScheduledSMSReminder` in `smsReminderManager.ts` or a parallel cron run, and the unhandled rejection aborts scheduling for all remaining reminders. Wrap it in its own try/catch or use `updateMany` so bookkeeping cannot fail the batch.

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

Non-atomic retryCount increment can be lost across concurrent runs — Overlapping cron runs both read the same `retryCount` and overwrite each other, so a lost increment leaves the reminder retried forever and the `retryCount > 1` cleanup never fires. Use Prisma's atomic `retryCount: { increment: 1 }` instead of the stale in-memory value.

mediumperformancepackages/features/ee/workflows/api/scheduleSMSReminders.ts:31-44

Unindexed retryCount OR arm causes WorkflowReminder full scan — The `retryCount` OR arm is unindexed, so the existing `@@index([method, scheduled, scheduledDate])` no longer serves this delete and every cron tick scans the whole `WorkflowReminder` table. Move the retry cleanup into its own `deleteMany` or index `retryCount`.

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