DeepSeek V4.1 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 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.077
Published comments (4)
Do not increment retryCount when SMS sending is locked — `twilio.scheduleSMS` returns `undefined` when sending is locked, and `checkSMSRateLimit` sets that state automatically once the monthly limit is hit, so a temporarily locked user permanently loses all reminders after two cron runs. Only increment `retryCount` for genuine provider errors and skip when sending is locked.
SMS cleanup deletes EMAIL and WHATSAPP reminders with retryCount > 1 — Without a `method` filter this SMS cron hard-deletes EMAIL and WHATSAPP `WorkflowReminder` rows whose `retryCount` exceeds 1. Scope the branch with `method: WorkflowMethods.SMS` so only SMS reminders can be deleted, matching `scheduleWhatsappReminders.ts`.
Unguarded retryCount update in catch can abort reminder batch — If `prisma.workflowReminder.update` throws — say P2025 after the new `deleteMany` removed the row — the exception escapes the loop and skips every remaining reminder in the batch. Wrap the increment in its own try/catch or use `updateMany` so error handling cannot abort the batch.
Missing index on WorkflowReminder retryCount causes cron full scan — No index supports `retryCount`, per `schema.prisma`, so this `deleteMany` full-scans the multi-million-row `WorkflowReminder` table on every cron run. Add an index on `retryCount` or on `(method, retryCount)` in the migration.