-
-
Notifications
You must be signed in to change notification settings - Fork 520
Description
I'm having issues with Raven reporting errors that happen inside of ActiveJob jobs when Raven is configured to send events in the background. When a job runs that triggers an exception, the background Raven job fires and eventually dies with this message:
ERROR: !!! ERROR HANDLER THREW AN ERROR !!!
ERROR: Can't serialize a Hash with reserved key "_aj_globalid"
ERROR: [edit]/activejob-4.2.4/lib/active_job/arguments.rb:126:in `serialize_hash_key'
I successfully reproduced this issues consistently in this test repository I created. It's a vanilla Rails 4.2.4 app, and all of the gems are up-to-date. I then added Raven and configured it to report in development and to report via background job. I also added Sidekiq. To exhibit the issue, perform the following steps:
- Clone the repo
- Migrate and seed the database
- Boot Sidekiq:
bundle exec sidekiq - Open up Rails console and run:
ExceptionJob.perform_later— successfully reports to SentryExceptionJob.perform_later([])— successfully reports to SentryExceptionJob.perform_later(Post.first)— failure
My assumption is that it fails because of the ActiveJob serialization. When the Sentry reporter job gets run, it serializes a hash that includes the parameters sent to ActiveJob. You can see in ActiveJob's source that they have a RESERVED_KEYS hash. Since the parameters sent to ActiveJob would contain a hash that has these keys, it would make sense that that is causing the issue.
I also tested this against the ActiveJob inline adapter, but it didn't seem to have the same issues. I only tested it against Sidekiq, which is what I was using when I noticed the issue.