deliver_later with Sidekiq causes 500 error when unable to connect to Redis
<p>In one of my Rails application controllers, I do something like this:</p>

<pre><code>def create
  @user = User.create(user_params)

  # send welcome email
  UserMailer.welcome(@user).deliver_later
end
</code></pre>

<p>Now, I've intentionally disabled my Redis server so that I can replicate what would happen in the case that a connection couldn't be made from my app.</p>

<p>Unfortunately, this entire <code>create</code> request fails with a 500 if the <code>deliver_later</code> is unable to connect to Redis.</p>

<p>What I'd like is that the request still succeeds, but the mailer fails silently.</p>

<p>How can I accomplish this?</p>

<p><strong>Additional information:</strong></p>

<p>In config/initializers/action_mailer.rb:</p>

<pre><code>  rescue_from(Redis::CannotConnectError) do |exception|
      Rails.logger.error "Original record not found: #{@serialized_arguments.join(', ')}"
  end
</code></pre>

<p>This never gets called though on exception. I tried <code>rescue_from(StandardError)</code> and <code>(Exception)</code>, but that was never called either.</p>

<p>I'm using sidekiq as my job queue adapter:</p>

<pre><code>config.active_job.queue_adapter = :sidekiq
</code></pre>

<p>The 500 error I get is:</p>

<pre><code>Redis::CannotConnectError (Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)):
</code></pre>

<p>My <code>UserMailer</code> is a subclass of <code>ApplicationMailer</code> which is a subclass of <code>ActionMailer::Base</code>.</p>