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