From b8b574117466a2e58c6b9117c9b53837d766553f Mon Sep 17 00:00:00 2001 From: Spruce Weber-Milne Date: Wed, 8 Jul 2026 10:27:32 -0700 Subject: [PATCH] Cancellation exception is not an error --- server/Helpers/LoggingMiddlewareHelper.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server/Helpers/LoggingMiddlewareHelper.cs b/server/Helpers/LoggingMiddlewareHelper.cs index 2bda801..e3f7afb 100644 --- a/server/Helpers/LoggingMiddlewareHelper.cs +++ b/server/Helpers/LoggingMiddlewareHelper.cs @@ -12,6 +12,17 @@ public static void UseApiFailureLogging(this WebApplication app) { await next(); } + catch (OperationCanceledException ex) + when (ctx.Request.Path.StartsWithSegments("/api") && ctx.RequestAborted.IsCancellationRequested) + { + app.Logger.LogInformation( + ex, + "API request was canceled by the client: {Method} {Path}. ContentLength={ContentLength}.", + ctx.Request.Method, + ctx.Request.Path, + ctx.Request.ContentLength); + throw; + } catch (Exception ex) when (ctx.Request.Path.StartsWithSegments("/api")) { app.Logger.LogError(