-
Notifications
You must be signed in to change notification settings - Fork 204
Change Timeout
middleware to return HTTP 503 Service Unavailable
status code
#579
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
base: main
Are you sure you want to change the base?
Change Timeout
middleware to return HTTP 503 Service Unavailable
status code
#579
Conversation
status code Returning HTTP `408 Request Timeout` status code wrongly indicates a client error.
While in general this does seem like a better error code, it's not always true. For instance, if the inner service times out because it's currently waiting on Looking at the linked issue, we could probably solve this by adding some configuration to the service/layer, so you can customize the response code returned. |
Doesn't that tie into EDIT: Uhh... no.
We'd have to take in a |
How about deprecating |
But the problem is, if we just provide a configuration with a fixed status code, that still does not solve the problem of "which case is it actually"? Or in other words, there's no way for the caller to do the right thing as well. |
Actually I believe we should challenge the entire assumption made here:
If we look at MDN docs for HTTP
Or the RFC 9110 section on HTTP
The general expectation seems to be that servers don't have to return these status codes, and could simply refuse or close the connection. So my proposal is, unless we have a way for the inner service to signal which kind of state it is currently in: |
Further thoughts: HTTP
(If it's important to return those specific HTTP status codes to distinguish where things hit a timeout.) Conclusion: I don't think Proposed solution: We should add documentation to suggest handling timeouts for the above 2 cases. |
Hi @jplatte, I really like this approach because I have the requirement of returning a 204 error on timeout. Should I open this proposal in a separate PR? |
Feel free to open a new PR, yeah. But what the heck are you doing where timeout should return 204 (which is certainly not an error code)? 😅 |
Motivation
See #300
Solution
Change
Timeout
middleware to return HTTP503 Service Unavailable
status code, as this is the most appropriate HTTP status code to the extent of its knowledge.Returning HTTP
408 Request Timeout
status code wrongly indicates a client error.