Blazor App Api Calls Cancelled

Tony Pitman 41 Reputation points
2023-04-03T18:55:56.4466667+00:00

I have a Blazor app based on net7 framework. It calls into several microservices that are also written in net7. Everything is being hosted on Azure in Container Apps using Docker. When I browse to the after it has gone to sleep (the timeout is about 5 minutes), several of the requests to the api's fail to complete. In the browser tools the status in the network tab is "cancelled". When I look at the timing tab in the browser tools it says the request "stalled". If I just hit refresh then everything loads fine. I have been assuming that this is due to the api's having to spin up, but that may not be the case. I am also trying to look at how the request is being made and from where exactly to help diagnose. There are sometimes when it works on the "first" try. When this happens the request is returned in about 7.5 seconds. When it fails on the "first" try, it has taken almost exactly 10 seconds. I have a few questions:
Any idea why the requests might be getting cancelled, but only on "first run"? Does the 10 seconds give any clues about what might be happening? Is there a way to generate and upload JS map files so the browser will have more information about the code being run? Is there a way to get more information about why exactly the request stalled? I am using Refit to make the api calls. Is there something I can set in Refit to help with diagnosing this issue?

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,477 questions
Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
325 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Mike Urnun 9,781 Reputation points Microsoft Employee
    2023-04-12T22:08:06.4833333+00:00

    Hello @Tony Pitman - Sorry for the late reply. Given how the stalling occurs only on the first run for a specific threshold of time of 10 seconds indicates a Cold Start behavior, similar to this issue: https://github.com/microsoft/azure-container-apps/issues/199 Depending on how you've stacked up the images & other related configurations, there may be some specific steps & optimizations you can make to reduce the overall spin-up time. I haven't used the Refit library firsthand but such client libraries usually offer properties or patterns that can be used to account for long-running requests so I would look for optimization opportunities in Refit as well.

    0 comments No comments

  2. Tony Pitman 41 Reputation points
    2023-04-12T22:13:04.6866667+00:00

    Turns out this was a case of not knowing another developer had introduced a setting that times out the refit client after 10 seconds. I increased this to 20 and now it works. What I still don't understand is why Polly didn't retry when it timed out.

    0 comments No comments