Rails 7.1: Issues with ActiveJob not retrying failed jobs when using custom error classes
I'm working on a personal project and I'm experimenting with After trying multiple solutions online, I still can't figure this out... I am experiencing an issue with ActiveJob in Rails 7.1 where my jobs are not being retried when they fail due to a custom error I’ve defined. I’ve set up a job that interacts with an external API, and sometimes it throws a `CustomAPIError` when the API is down. Here’s my job implementation: ```ruby class ApiFetchJob < ApplicationJob queue_as :default retry_on CustomAPIError, attempts: 5, wait: :exponentially_backoff def perform(api_endpoint) response = ExternalApiClient.get(api_endpoint) # Process the response... end end ``` When the external API is down, I receive the following error in my logs: ``` ActiveJob::QueueAdapter: Failed to execute job: CustomAPIError ``` The job does not seem to retry even though I’ve specified the `retry_on` directive. I’ve verified that `CustomAPIError` is being raised, but the job just fails silently without retries. I also checked my application’s configuration for ActiveJob: ```ruby # config/application.rb config.active_job.queue_adapter = :sidekiq ``` I have Sidekiq set up properly, as I can see other jobs processing without issues. I’ve tried to explicitly catch the `CustomAPIError` within the `perform` method and re-raising it to no avail. Have I missed something in the job declaration or configuration? Are there any known issues regarding custom error handling in ActiveJob with Sidekiq? Any insights would be greatly appreciated! For context: I'm using Ruby on Linux. I'd really appreciate any guidance on this. Am I approaching this the right way? This is part of a larger application I'm building. Am I approaching this the right way?