Skip to content

Commit f5bf252

Browse files
committed
fix(DbContextHealthCheck): propagate OperationCanceledExceptions instead of reporting unhealthy
1 parent c7415ff commit f5bf252

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Middleware/HealthChecks.EntityFrameworkCore/src/DbContextHealthCheck.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Data.Common;
45
using Microsoft.EntityFrameworkCore;
56
using Microsoft.Extensions.Options;
67

@@ -41,7 +42,7 @@ public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context
4142

4243
return new HealthCheckResult(context.Registration.FailureStatus);
4344
}
44-
catch (Exception exception)
45+
catch (Exception exception) when (exception is not OperationCanceledException || !cancellationToken.IsCancellationRequested)
4546
{
4647
return HealthCheckResult.Unhealthy(exception.Message, exception);
4748
}

0 commit comments

Comments
 (0)