grpc/grpc-dotnet

OperationCanceledException thrown when canceling a CancelationToken does not reference the token canceled when using Retries

Watno opened this issue · 0 comments

What version of gRPC and what language are you using?

Grpc.Net.Client 2.58.0, C#

What operating system (Linux, Windows,...) and version?

Windows 11

What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info)

SDK 7.0.402

What did you do?

The situation is similar to #2014: OperationCanceledException thrown when canceling a CancelationToken does not reference the token canceled
When having Retries enabled in the GrpcClient, (i.e. when specifying a RetryPolicy with MaxRetryAttemps > 0 in the ClientConfiguration), the client is called and then the CancelationToken passed is cancelled before the gRPC call completes.

What did you expect to see?

An OperationCanceledException with the CancelationToken passed.

What did you see instead?

An OperationCanceledException with a different CancelationToken than the one passed.
Stacktrace of the exception:

 ---> System.OperationCanceledException: The operation was canceled.
   at System.Threading.CancellationToken.ThrowOperationCanceledException()
   at Grpc.Net.Client.Internal.Retry.RetryCall`2.StartRetry(Action`1 startCallFunc)
   --- End of inner exception stack trace ---
   at Grpc.Net.Client.Internal.Retry.RetryCallBase`2.GetResponseCoreAsync()```