-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid logging bad requests as application errors if the connection was aborted #60359
Avoid logging bad requests as application errors if the connection was aborted #60359
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
Unit tests? One where the message is logged (open connection) and another that verifies it isn't (closed connection) |
150c32e
to
e6d4ca8
Compare
Added a new test for the aborted connection scenario and piggybacked on an existing one for the other case where we want to keep the message the same. |
Change the behavior in Kestrel's request processing logic so that bad requests are only logged as errors if the connection has not been aborted. This reduces noise in the logs for common client errors.
We already expose bad request information via
Microsoft.AspNetCore.Server.Kestrel.BadRequests
so anyone who is interested in seeing all of this already has a mechanism for doing so, and we don't show scary "fail" messages to people who don't care.This issue has been a source of great frustration for years now (#23949), and generally, there's nothing the server dev can do when there's an unexpected client behavior (e.g. aborting a connection before completing a request) so this seems like a sane default.
Fix #23949