DeepSeek V4 Pro · 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
- 4 of 6
- Comments published
- 5
- Comments matching a bug
- 4
- Comments not matching
- 1
- Cost of this PR
- $0.656
Published comments (5)
Locked SMS account wrongly increments retryCount in else branch — When SMS sending is locked, `twilio.scheduleSMS` returns `undefined` instead of throwing, so this `else` branch counts a lock as a send failure and increments retryCount. Pending reminders for a locked account are deleted after two cron runs without any send attempt, so they are permanently lost if the lock is later removed.
Second OR branch lacks SMS method filter, deleting non-SMS reminders — The second OR branch `{ retryCount: { gt: 1 } }` is missing the SMS method filter. This endpoint is meant to clean up SMS workflow reminders only, but this branch will delete any WorkflowReminder of any method (email, etc.) once its retryCount exceeds 1.
Off-by-one retry threshold deletes SMS reminders after one retry — The retry limit is off by one relative to the value being measured. `retryCount` is incremented on every failed attempt including the initial one (lines 184 and 195), but this deletion condition removes reminders when `retryCount > 1`.
Wrap retryCount update in its own try/catch to preserve best-effort catch behavior — The new awaited prisma.workflowReminder.update inside the catch block changes the error contract: previously a scheduling error was swallowed and logged, and the loop continued to the next reminder. Now, if this retryCount update throws (e.g. transient DB failure or the reminder was deleted), the error escapes the catch and aborts the whole cron run, causing remaining reminders to be skipped and the request to fail.
Non-atomic retryCount increment permits indefinite SMS retries — `retryCount` is updated with a non-atomic read-modify-write (`reminder.retryCount + 1`) using the value read at findMany time. Two overlapping cron invocations both read the same stale value and write the same incremented result, so retryCount never reaches 2 and the reminder is retried indefinitely, defeating the new retry cap. **Also found in:** - `packages/features/ee/workflows/api/scheduleSMSReminders.ts:178-186`