AspNetCore.Diagnostics.HealthChecks icon indicating copy to clipboard operation
AspNetCore.Diagnostics.HealthChecks copied to clipboard

Unexpected timeout exception

Open MaxiPigna opened this issue 1 year ago • 3 comments

Given this source code

builder.Services.AddHealthChecks()
    .AddAzureCosmosDB(optionsFactory: static (sp) =>
    {
        CosmosDbOptions cosmosConfig = sp.GetRequiredService<IOptions<CosmosDbOptions>>().Value;
        return new AzureCosmosDbHealthCheckOptions
        {
            DatabaseId = cosmosConfig.DatabaseName,
            ContainerIds = [Constants.ConversationContainerName]
        };
    }, tags: ["Database"], timeout: TimeSpan.FromSeconds(2))

It works most of the time, but sometimes I find exception like this in the log, why? image

I think it's weird I get a timeout exception, while Cosmos replied 200 OK in the expected time.

Environment:

  • .NET 8 version
  • AspNetCore.HealthChecks.CosmosDb version 8.0.0
  • Linux Azure App Service

MaxiPigna avatar Jun 06 '24 10:06 MaxiPigna

Did you ever find out what the cause of this was? I'm experiencing similar exceptions

dankarmyy avatar Oct 15 '24 09:10 dankarmyy

Nope 😢

MaxiPigna avatar Oct 15 '24 16:10 MaxiPigna

Hey guys, whatever is configured to check the application health has a low timeout of 2s, if the application fails to respond in this time, the request will be cancelled, and the CancellationTokens will do what they're supposed to do and end up throwing OperationCancelledException like you're getting.

bison92 avatar May 27 '25 14:05 bison92