Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollbar reports Action Mailer errors that are handled with discard_on and rescue_from in the delivery job #1177

Open
mrhead opened this issue Feb 18, 2025 · 1 comment

Comments

@mrhead
Copy link

mrhead commented Feb 18, 2025

Since version 3.5.1, Rollbar reports errors raised from Action Mailer even if they are handled with discard_on or rescue_from in the delivery job.

In fact, this behavior changed in 3.5.0, but this version fails because of #1145.

Steps to reproduce

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  gem "rails"
  gem "rollbar", ENV["ROLLBAR_VERSION"]
  gem "minitest"
end

require "rails/all"
require "rollbar"
require "minitest/autorun"

ActiveJob::Base.queue_adapter = :async
ActiveJob::Base.queue_adapter.immediate = true

Rollbar.configure do |config|
  config.access_token = "dummy token"
end

class InactiveRecipientError < StandardError; end

class TestDeliveryJob < ActionMailer::MailDeliveryJob
  discard_on InactiveRecipientError
end

class TestMailer < ActionMailer::Base
  self.delivery_job = TestDeliveryJob

  def mail(to:)
    raise InactiveRecipientError # simulate error
  end
end

class RollbarReportingTest < Minitest::Test
  def test_rollbar_reports_abort_email_exception
    TestMailer.mail(to: "[email protected]").deliver_later

    assert_nil Rollbar.last_report, "Rollbar should not report InactiveRecipientError exception"
  end
end

Save the script to rollbar_actionmailer.rb and run it with:

ROLLBAR_VERSION=3.5.1 ruby rollbar_actionmailer.rb

You can also test it with Rollbar in 3.5.0; however, 3.5.0 fails because of #1145.

ROLLBAR_VERSION=3.5.0 ruby rollbar_actionmailer.rb

Expected behavior

The InactiveRecipientError error should not be reported, and the test should pass as it does with Rollbar 3.4.2.

ROLLBAR_VERSION=3.4.2 ruby rollbar_actionmailer.rb

Actual behavior

The error is reported even if it is handled by discard_on or rescue_from in the delivery job and the test fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant