-
Notifications
You must be signed in to change notification settings - Fork 494
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
Make CosmosOperationCanceledException Serializable #3402
Comments
@brianwp3000 Before, the SDK would throw Were you able to serialize |
Ok did some more investigation on my end: We are running a service on Microsoft Orleans, which runs code on distributed processes called "grains". Anything passed between these grains has to be serialized, including Exceptions. Back when we were running CosmosSDK 3.20.1 we were still running into CosmosOperationCanceledException that Orleans couldn't serialize. But, Orleans would throw a NullReferenceException during serialization and we caught that exception gracefully:
Now that we've upgraded to CosmosSDK 3.29.0, Orleans is presumably still failing to serialize correctly but it doesn't throw an exception. Instead, we run into the NullReferenceException at runtime when we call ToString() on the CosmosOperationCanceledException:
We had to add another try-catch to guard against these new exceptions. Before we added the new try-catch, we got some crash dumps that point to line 103 in CosmosOperationCanceledException.cs as the line that threw the NullReferenceException. So admittedly Orleans serialization is introducing more complexity here than there needs to be, but all this would be solved if CosmosOperationCanceledException was serializable. |
Got it. We can track making |
@NaluTripician please see the above comment |
My team just upgraded from 3.20.1 to 3.29.0 and we are now running into problems because
CosmosOperationCanceledException
no longer works with the Microsoft Orleans binary serializer.Azure-sdk-for-net ran into this same issue a few years ago, and solved it by implementing
Serializable
on theirException
classes.It's a best practice to always make
Exception
classesSerializable
. Without this, my team has to work around the issue by catching all CosmosExceptions and wrapping them in another Exception that implements Serializable.The text was updated successfully, but these errors were encountered: