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

resque: be more specific when handling ActiveJob wrapped jobs #710

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/bugsnag/integrations/resque.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def save

# when using Active Job the payload "class" will always be the Resque
# "JobWrapper", not the actual job class so we need to fix this here
if metadata['args'] && metadata['args'][0] && metadata['args'][0]['job_class']
if class_name == 'ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper' && metadata['args'] && metadata['args'][0] && metadata['args'][0]['job_class']
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a risk here that this may be too specific or accidentally a breaking change – either because it doesn't account for an ActiveJob-specific quirk, or because the existing code was coincidentally unwrapping exceptions from other frameworks. An alternative implementation would be wrapping this existing logic in a begin/rescue; it would still fail, but in a way that is less disruptive than the existing implementation. I'm open to going that way if it's preferred by maintainers

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good way to do it 🙂

I was considering checking if ['args'][0] is a hash or responds to [] but, given this is specifically to unwrap the Active Job class, it makes sense to me to make it specific to Active Job

class_name = metadata['args'][0]['job_class']
metadata['wrapped'] ||= class_name
end
Expand Down