Skip to content

Suppress exceptions for aborted requests - #404

Merged
nblumhardt merged 1 commit into
serilog:devfrom
Solution-lab:ignore-canceled-request-exceptions
Aug 17, 2026
Merged

nblumhardt merged 1 commit into
serilog:devfrom
Solution-lab:ignore-canceled-request-exceptions

Conversation

@Solution-lab

Copy link
Copy Markdown
Contributor

Fixes #372.

Summary

RequestLoggingMiddleware no longer attaches an escaping OperationCanceledException or IOException to the completion event when HttpContext.RequestAborted is cancelled.

The completion event is still emitted, the exception continues to propagate through the middleware pipeline, and exceptions collected through IDiagnosticContext.SetException() remain attached.

Rationale

This follows ASP.NET Core's request-abort handling. IOException was included intentionally (aspnetcore#46330 discussion), and the exception is omitted to avoid noisy, non-actionable stack traces (Tratcher's comment).

Tests

Tests cover both cancellation exception types, non-aborted cancellation, and preservation of collected exceptions.

@nblumhardt

Copy link
Copy Markdown
Member

Thanks! Current trajectory will have this out in a v11.0 in a couple of months.

@nblumhardt
nblumhardt merged commit 2002d1f into serilog:dev Aug 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not log exception call stacks for cancellations in RequestLoggingMiddleware

2 participants