question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Describe the bug

Using a Polly Policy in blazor on httpclient does not execute policy on a transient failure.

To Reproduce

Steps to reproduce the behavior: Using the code below:

using System;
using System.Collections.Generic;
using System.Net.Http;
using Microsoft.AspNetCore.Components.Builder;
using Microsoft.Extensions.DependencyInjection;
using Polly;

namespace Web.Client
{
    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
             // custom wasm request handler to add a bearer token to each internally matching request
             services.AddSingleton(x => new HttpClient(new TokenWebAssemblyMessageHandler(x.GetService<ITokenService>())));

            // add polly wait and retry policy
            services.AddHttpClient<IMicroServiceClient, SomeMicroserviceClient>()
                .AddTransientHttpErrorPolicy(builder => builder.WaitAndRetryAsync(new[]
                {
                    TimeSpan.FromMilliseconds(300),
                    TimeSpan.FromMilliseconds(600),
                    TimeSpan.FromMilliseconds(900),
                    TimeSpan.FromMilliseconds(1200)
                }));

            services.AddSingleton<AppState>();
        }

        public void Configure(IComponentsApplicationBuilder app)
        {
            app.AddComponent<App>("app");
        }
    }
}

Expected behavior

When the httpclient makes a failed call, i.e. response in the 5xx and 4xx ranges, should retry the request per the orders of policy.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mkArtakMSFTcommented, May 31, 2019

Thanks @pdeveau. We’re wrapping up upcoming releases now and will be able to get to this only after that.

0reactions
mkArtakMSFTcommented, Oct 19, 2022

Hi. Thanks for contacting us. We’re closing this issue as there was not much community interest in this ask for quite a while now. You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found