dotnet / dotnet/extensions

HTTP resiliency features don't work with the .NET gRPC client

Open
#4,923 9 comments 10 reactions 0 assignees View on GitHub
api-suggestion area-resilience
Dominant language
C#
Stars
3.2k
Forks
894
Avg merge
1d 12h
Merged PRs (30d)
23

Description

The HTTP resiliency features, including those added by the `IHttpClientBuilder.AddStandardResilienceHandler` method, don't apply to gRPC calls despite them going through configured `HttpClient` instances. This is due to the gRPC stack not exposing error details at the HTTP request level in the way that the resiliency features expect (e.g. using HTTP status codes).

The following code example, typical of setting up a gRPC client in a .NET server application, will not actually result in the standard resiliency features being applied to gRPC calls:

```csharp
builder.Services.AddGrpcClient(o => o.Address = new("http://basket-api"))
.AddStandardResilienceHandler();
```

Consider adding support for the standard resiliency patterns to the .NET gRPC client stack in a similar fashion to those added to the `HttpClient` stack so that resiliency features like Circuit Breaker can be easily added by default.

/Cc @JamesNK @davidfowl

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.