Skip to content

Commit

Permalink
Set Sidekiq retries to 3 even for ActionMailer::MailDeliveryJob
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
floehopper committed Jan 10, 2024
1 parent 82b6fe5 commit 44ca9c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 0 additions & 2 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

Sidekiq.default_job_options = { retry: 3 }

0 comments on commit 44ca9c7

Please sign in to comment.