qiushihe / delayed-plugins-raven

DelayedJob exception notification with Sentry Raven
Other
1 stars 3 forks source link

NoMethodError: undefined method `flush' for #<Logger:0x007fcbbdad1d18> #5

Open mikeatlas opened 10 years ago

mikeatlas commented 10 years ago

I'm hitting this when Raven logging itself fails and then flushing the logger fails:

https://github.com/qiushihe/delayed-plugins-raven/blob/master/lib/delayed-plugins-raven.rb#L19

undefined methodflush' for # /gems/delayed-plugins-raven-1.0.5/lib/delayed-plugins-raven.rb:19:in rescue in error' /gems/delayed-plugins-raven-1.0.5/lib/delayed-plugins-raven.rb:12:inerror'`

Any thoughts? Rails 4.0.5, delayed_job 4.0.1

mikeatlas commented 10 years ago

This is because I'm getting json nil on line 27, which results in json.delete call failing...

json = job.as_json["job"]

mikeatlas commented 10 years ago

hello @qiushihe, are you still maintaining this gem?

qiushihe commented 10 years ago

Hi, yes I am maintaining this gem.

What is the actual exception that got rescued on line 17 (line 18 logs it as "Raven logging failed: #{e.class.name}: #{e.message}")?

Also, I am using DelayedJob 4.0.1 in a production environment and it's working fine for me. Although I'm using Rails 4.1. Could you try and see what the output is for this:

Delayed::Job.last.as_json

... it's something like this for me:

{"job"=>{"id"=>40299504, "priority"=>0, "attempts"=>0, "handler"=>"...", "last_error"=>nil, ... }}
mikeatlas commented 10 years ago

get_job_json(job) is returning nil (I don't know why?) but then line 30 json.delete(attribute) throws an exception itself (can't call delete on nil), and the call to Raven thus never happens.

qiushihe commented 10 years ago

Line 30, json.delete(...) throws the exception, because json is nil. And that's because job.as_json["job"] is nil for some reason.

If you see what I've posted about my output, job.as_json should return a job-namespaced hash for the job. And for some reason, it's not doing that for you.

That's why I wanted you to try and see what the output of Delayed::Job.last.as_json is. You can run that in a rails console.