-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
How should Body
handle errors?
#1951
Comments
If not for |
hyper doesn't ignore errors, an error from a body means the connection gets closed abruptly. Transmission and generations of bodies can fail part-way through, so |
In that case I think the only time when we should actually handle errors for For upgraded requests where connections are kept open though, it certainly makes sense to handle errors for |
The primary use case I have in mind is making it easy to log the error or send it to whatever error reporting system a user wants to use. |
Maybe we can just do a simple |
Indeed, i just shot my foot :-) In the serve with hyper example, on an error, no 500 responses are returned, it just closes the connection abruptly. Im happy to contribute a PR to "fix" the example if there anyone has pointers. My question becomes, how does one take those errors and make hyper return a 500 from it ? |
@happysalada that's impossible, at the time the body error is generated, the status code has already been encoded and possibly sent. |
This makes sense. I seem to remember that an error in the stream caused a panic and the server to stop accepting request. It seems in this case, closing the connection abruptly makes sense, it should just fail gracefully and leave am option to log the error somewhere |
I'm not really seeing anything actionable here, as noted by Sean, |
In 0.7 axum is getting its own
Body
type. Currently hyper just ignores errors produced by bodies which is a bit of a footgun. We should consider whether axum's body should useInfallible
as the error type.The text was updated successfully, but these errors were encountered: