Rails 8.2 introduces an enhancement to ActiveJob's retry_on that allows retry logic to inspect the actual error object, not just execution count. This enables intelligent retry strategies that can respect API rate limit headers, extract retry hints from exception messages, adapt delays based on HTTP status codes, and make context-aware decisions. The article demonstrates practical patterns including respecting Retry-After headers, handling lock timeouts with jitter, differentiating between transient and permanent failures, and building reusable retry strategy modules.
Table of contents
The Old WayThe New WayPatternsError Classes That Carry ContextCombining with discard_on115 Impressions