Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

gRPC client + AddStandardResilienceHandler: Unavailable instead of Cancelled

Minimal repro for a bug in the Polly version that Microsoft.Extensions.Http.Resilience pins (8.4.2).

A gRPC client set up through Grpc.Net.ClientFactory with AddStandardResilienceHandler() is cancelled by the caller while an attempt is in flight. The attempt then completes with a transient HTTP failure (503). The call should fail with StatusCode.Cancelled; on Polly 8.4.2 it fails with StatusCode.Unavailable.

Root cause: Polly's retry strategy returned the last failed outcome instead of throwing when the token was cancelled. Fixed in Polly 8.5.2 (App-vNext/Polly#2456). A plain HttpClient hides it, because it checks the token itself after the handler chain returns; Grpc.Net.Client goes through HttpMessageInvoker, which doesn't.

Run

dotnet run
Polly.Core: 8.4.2+077cf388fc5a85a7f6cd0fdcb2b68d17a898019e
FAIL: RpcException with StatusCode.Unavailable

Same code, newer Polly:

dotnet run -p:PollyVersion=8.7.0
Polly.Core: 8.7.0+a824c6b9258daa2879b8fa2ea768bf06bd5e6cf0
PASS: RpcException with StatusCode.Cancelled

Written with help from Claude Code; the output above is from running it.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages