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

Fix for double ActiveJob::DeserializationErorr #16785

Merged

Conversation

cristianbica
Copy link
Member

If an argument that cannot be serialized is not in the first level of arguments (it's in an array or hash) the error is double wrapped inside DeserializationError. Example:

# enqueueing the Person object from the AJ testing wrapped in an array
RescueJob.enqueue [Person.new(404)]
# will raise 

> puts e.inspect
#<ActiveJob::DeserializationError: Error while trying to deserialize arguments: Error while trying to deserialize arguments: Cannot find person with ID=404>

> puts e.class.name
ActiveJob::DeserializationError

> puts e.original_exception.class.name
ActiveJob::DeserializationError

> puts e.original_exception.original_exception.class.name
Person::RecordNotFound

@matthewd
Copy link
Member

matthewd commented Sep 3, 2014

I think we'd be better off moving the rescue to the outer/public deserialize method, and only using that once (i.e., not calling back to it in the Array case). It seems quite a waste of effort to potentially construct a stack of rescues that we'll end up ignoring.

@cristianbica
Copy link
Member Author

@matthewd It's the same thing as serialize_argument will call serialize when it finds an array. So a traceback will look like this:
serialize -> calls serialize_argument and will rescue and wrap the exception
serialize_argument - will find an array or hash and call serialize
serialize -> calls serialize_argument and will rescue and wrap the exception
serialize_argument - will call GlobalID::Locator which will raise
So the exception raised by GlobalID::Locator will be rescued twice.

@cristianbica cristianbica force-pushed the fix-double-aj-deserialization-error branch 2 times, most recently from 267ed70 to 05ed1ef Compare September 3, 2014 11:23
@cristianbica cristianbica force-pushed the fix-double-aj-deserialization-error branch from 05ed1ef to 56f992f Compare September 3, 2014 11:24
matthewd added a commit that referenced this pull request Sep 3, 2014
…tion-error

Fix for double ActiveJob::DeserializationErorr
@matthewd matthewd merged commit e2ce4c7 into rails:master Sep 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants