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

Exception from Delayed::Job not reported if job fails to deserialize #472

Closed
adamniedzielski opened this issue May 24, 2016 · 6 comments
Closed
Assignees
Labels
Milestone

Comments

@adamniedzielski
Copy link

If Delayed::Job fails to deserialize a job it throws DeserializationError. This happens early in the process and the hook lifecycle.around(:invoke_job, &Delayed::invoke_job_callback) is not called.

Looking at the code it is rescued here https://github.com/collectiveidea/delayed_job/blob/1e679174b513dc711f7d764c8bd9d4f5c6495276/lib/delayed/worker.rb#L235-L237 and the only hook it calls is "failure".

Do you have any idea how we can account correctly for this case?

@jondeandres
Copy link
Contributor

@adamniedzielski do you know the reasons of the DeserializationError? Do you think that has a relation with the gem itself? Or is just that you'd like to report this errors?

@adamniedzielski
Copy link
Author

adamniedzielski commented Jun 2, 2016

@jondeandres Thanks for your response!

The DeserializationError comes from the Delayed Job and has no relation with the Rollbar gem. I would like this exception to be reported by Rollbar, because it prevents the job from executing and this is something I definitely want to be aware of 😄

@adamniedzielski
Copy link
Author

adamniedzielski commented Jul 5, 2016

Quick way to reproduce the problem:

"abc".delay.first(->{})
Delayed::Worker.new.run(Delayed::Job.last)

I think that now I understand why this gem uses around(:invoke_job) rather than after(:error) or after(:failure) - the exception is not available for these callbacks.

In order to have a basic reporting for jobs which failed even before the first execution we would have to add something similar to:

class RollbarPlugin < ::Delayed::Plugin
  callbacks do |lifecycle|
    lifecycle.around(:invoke_job, &Delayed::invoke_job_callback)
    lifecycle.after(:failure) do |_, job|
      ::Rollbar.error("Delayed::Job ID=#{job.id} failed to execute") if job.attempts.zero?
    end
  end
end

@jondeandres
Copy link
Contributor

Hey @adamniedzielski, thanks for this, we'll try to release a new version with this soon.

@coryvirok coryvirok added the bug label Jun 8, 2017
@rokob rokob added this to the v2.16.0 milestone Jun 19, 2017
@rokob rokob closed this as completed in da3708b Jul 28, 2017
@adamniedzielski
Copy link
Author

Thanks @richvorp! 💚 💯 🎉

@yoonwaiyan
Copy link

Really hope to get this released asap, delayed job failure is high in a server under my monitor.

@ArturMoczulski ArturMoczulski modified the milestones: v2.17.0, v2.16.0 May 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants