-
Notifications
You must be signed in to change notification settings - Fork 279
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
Incorrect behaviour in DelayedJob #291
Comments
More info about this bug: it works with |
Pull request #292 fixes this. |
What version of delayed_job were you seeing this in? I am fairly confident that this has worked in the past, so I'm guessing it may be broken in the latest version / some other version than we are already testing in. We'll want to update the test suite to make sure it covers this. |
I use |
It doesn't look like a delayed_job issue. Last time we received a delayed_job error was right before we upgraded from 1.5.2. to 2.1.1... Looks like the problem was introduced when the enforce_valid_utf8 method in /lib/rollbar.rb was changed from def enforce_valid_utf8(payload)
normalizer = lambda do |object|
is_symbol = object.is_a?(Symbol)
return object unless object == object.to_s || is_symbol
# ...removed some code here...
end
Rollbar::Util.iterate_and_update(payload, normalizer)
end to def enforce_valid_utf8(payload)
normalizer = lambda { |object| Encoding.encode(object) }
Rollbar::Util.iterate_and_update(payload, normalizer)
end Note the return object unless object == object.to_s in the old method, whereas in the new one the object is immediately converted to String: def encode
value = object.to_s
encoding = value.encoding
# This will be most of cases so avoid force anything for them
if encoding == ::Encoding::UTF_8 && value.valid_encoding?
encoded_value = value
else
encoded_value = force_encoding(value).encode(*encoding_args(value))
end
object.is_a?(Symbol) ? encoded_value.to_sym : encoded_value
end #292 ensures data.request is already the right JSON String instead of it becoming something like "#Delayed::Backend::ActiveRecord::Job:0xf474fc8" when UTF8 encoding is enforced. |
Since serialization is made by JSON, we crashed delayed job reports cause we were exploting the JSON & ActiveSupport bug. Now we get the job data from job.payload_object.as_json. I've added tests for this, testing two different scenarios: - method without arguments - method with arguments
Since serialization is made by JSON, we crashed delayed job reports cause we were exploting the JSON & ActiveSupport bug. Now we get the job data from job.payload_object.as_json. I've added tests for this, testing two different scenarios: - method without arguments - method with arguments Delete delayed_jobs before each spec. Use job.as_json for delayed_job.
Fix delayed_job crash reports. Fixes #291
I recently noticed that Rollbar doesn't work in my DelayedJob tasks. Tried to debug: just placed
raise 'h'
in the delayed method and runDelayed::Job.last.invoke_job
from rails console. This is the result:Any ideas what is wrong?
The text was updated successfully, but these errors were encountered: