-
Notifications
You must be signed in to change notification settings - Fork 281
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
Fix ActionMailer plugin to add rescue_from
to the correct class
#1143
Conversation
cb80d3e
to
752d68b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, thanks for the description in the PR help clear up the context
def self.included(base) | ||
base.send :rescue_from, Exception do |exception| | ||
args = if self.class.respond_to?(:log_arguments?) && !self.class.log_arguments? | ||
arguments.map(&Rollbar::Scrubbers.method(:scrub_value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @waltjones, I noticed that the rollbar update to 3.5.0 broke one of the mailers of our app and tracked it down here: ActionMailer::Base
doesn't have an arguments
method and NameError: undefined local variable or method 'arguments' for #<YourMailerClass:0x0000000036ada8>>
here
I assume this was fixed on the tests here with the attr_accessor :arguments
on the TestMailer, but that doesn't happen on a regular rails app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lucasmazza Thank you for the report. I'm working to get a fix out today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lucasmazza Fix is released in 3.5.1. https://github.com/rollbar/rollbar-gem/releases/tag/v3.5.1
else | ||
arguments | ||
end | ||
Rollbar.plugins.define('active_job') do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 - this change produces:
NameError: uninitialized constant Rollbar::ActiveJob (NameError)
include Rollbar::ActiveJob
^^^^^^^^^^^
which means that https://docs.rollbar.com/docs/activejob-integration is no longer true. Is there a change required to the documentation?
https://docs.rollbar.com/docs/gem-plugins is unclear on how plugins are loaded, so we were unable to experiment with a solution.
Description of the change
This PR has two fixes.
ActiveJob
plugin is now a true plugin, with all of the methods and capabilities that should be present. It now loads at the correct load time, and can be disabled from the Rollbar config. d3e0029rescue_from
handler is added to the correct base class. 4d4f391This PR also refactors the tests to test Rails 6+, which previously didn't get coverage that included the mailer class. Where possible, the tests are now in shared examples called by both the old and new contexts.
Background facts about
rescue_from
handlers.When
MailDeliveryJob
was added in Rails 6.x, it included arescue_from
handler that calls therescue_from
of the Mailer class.When the Rollbar
ActiveJob
plugin installs its handler onMailDeliveryJob
, it is added after the one in theMailDeliveryJob
class, and has precedence. This causes the intended handler to never get called, and therefore never pass the error to the Mailer class.ActionMailer::Base
is the base class for all Mailers, and this is the correct place to add the Rollbar handler. With this fix, the application's handler will be used if it matches the exception class, and if not, the Rollbar handler is called.Type of change
Related issues
Fixes #1126