{
  "id": 22226855,
  "title": "The message that retried hundreds of times: a retry loop with no exit",
  "url": "https://urgent.news/2026/11/27/the-message-that-retried-hundreds-of-times-a-retry-loop-with-no-exit",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-27T20:17:29.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/ericgitangu/the-message-that-retried-hundreds-of-times-a-retry-loop-with-no-exit-5027"
  },
  "original_language": "en",
  "account": "The story revolves around a single text message that was retried hundreds of times due to a retry loop with no exit. The issue began when the SMS provider rejected the system's account as inactive. Rather than expected, one queued message kept coming back, with the same recipient, across several days. Each attempt was answered with a refusal, leading to hundreds of retries.\n\nThere were three small decisions that led to this situation: the send helper had no catch, provider errors were thrown instead of returned, and the worker saved progress only after the recipient loop finished. This allowed an error to escape, leaving the row in \"in progress\" status, and the reclaim timer re-picked the row after a few minutes, thinking the worker had crashed.\n\nThe problem was exacerbated by the fact that the run aborted at the first failing recipient, starving the remaining recipients in the same row. The decision to keep the reclaim timer in place was made because it had good reasons for existing, but a way was needed for a row to explicitly state it had failed and not be picked up again.\n\nTo address this, a catch was added per recipient, so one bad send couldn't abort the run or hide behind others. Attempts were counted on the row itself, with exponential backoff and a cap, after which the row was marked as failed with a terminal failure and reason. The reclaim query was also taught to respect a \"not before\" stamp, preventing re-picking of rows with a retryAfter stamp.\n\nThe solution is a small pure class that handles three outcomes: 'sent', 'failed', and 'retry'. It doesn't perform any I/O of its own and takes everything it needs as arguments, making it easy to test. The 'retry' outcome has a reason, which is different from the 'failed' outcome. Storage errors are not swallowed and are handled separately.\n\nOnce a row is marked as failed, it is put back in the row's \"already handled\" list and won't be sent to again. Before the cap, failed recipients are removed from that list, allowing the next attempt to retry them. The reclaim query ensures that a row is selectable only if it has no retryAfter or the stamp is due.\n\nThe worker reads the provider's account state as a gauge, skipping sends for affected recipients if the gauge says 'down'. If the gauge is missing or unreadable, the worker treats it as up and attempts the send. Changes are logged and an alert is raised when the state flips, reducing the number of alerts.",
  "summary": "I'm Eric Gitangu. I work on backend systems for a mobility/fintech platform. This is the story of one text message that was retried hundreds of times, and what it took to teach the code to take no for an answer. The symptom A cron worker sends queued notifications. One day the SMS provider started rejecting our account as inactive. Annoying, but a provider outage is supposed to be a boring day:…",
  "summary_source": "publisher",
  "key_points": [
    "Retry loop with no exit led to hundreds of SMS message retries",
    "Three small decisions caused the issue: no catch, error thrown, progress saved prematurely",
    "Catch per recipient, exponential backoff, and \"not before\" stamp resolved the problem"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}