From 44ca9c734f6fce779fcafbb4f537d693c845ea5c Mon Sep 17 00:00:00 2001 From: James Mead Date: Wed, 10 Jan 2024 21:24:27 +0000 Subject: [PATCH] Set Sidekiq retries to 3 even for ActionMailer::MailDeliveryJob MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `ActionMailer::MailDeliveryJob` inherits from `ActiveJob::Base` [1]; not from `ApplicationJob`. I suspect that's why the retry option in `ApplicationJob` didn't seem to be having any effect on jobs created by sending an email. It's hard to get a definitive answer, but I'm fairly confident setting the `retry` option on `Sidekiq.default_job_options` should apply globally to all jobs sent to Sidekiq, i.e. including `ActionMailer::MailDeliveryJob`. Fixes #143 (hopefully!🤞) [1]: https://github.com/rails/rails/blob/23938052acd773fa24068debe56cd892cbf8d868/actionmailer/lib/action_mailer/mail_delivery_job.rb#L13 --- app/jobs/application_job.rb | 2 -- config/initializers/sidekiq.rb | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 config/initializers/sidekiq.rb diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb index 60ba1d59..bef39599 100644 --- a/app/jobs/application_job.rb +++ b/app/jobs/application_job.rb @@ -6,6 +6,4 @@ class ApplicationJob < ActiveJob::Base # Most jobs are safe to ignore if the underlying records are no longer available # discard_on ActiveJob::DeserializationError - - sidekiq_options retry: 3 end diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb new file mode 100644 index 00000000..c3c84827 --- /dev/null +++ b/config/initializers/sidekiq.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +Sidekiq.default_job_options = { retry: 3 }