Closed S-Abhishek closed 1 month ago
This is just old behavior for all unhandled errors. So this issue is really just a feature request to add another error. Before, all errors were lazily caught as timeout errors and timeout happens roughly after 10 seconds (8-12 seconds)
@uNetworkingAB I understand,
Since uWebsockets enforces UWS_HTTP_MAX_HEADERS_COUNT
- this could be a handled case now with a response sent similar to max header size increase with body indicating the count limit breach. This helps from a consumer perspective with debugging 502 errors as we expect a 4XX
error for such scenarios and it becomes hard to ascertain what caused the actual 502s due to an empty response. Making the errors more clear would help.
On that same note, regarding the old timeout behavior, A response indicating the timeout instead of an empty response also helps consumers greatly.
Let me know what you think of this and whether there are any plans to change this 👍
It should be a new error. Btw, you can't signal timeout in HTTP - there is no "push" you must wait for a request so timing out has to be "silent".
It should be a new error.
Got it,
Btw, you can't signal timeout in HTTP - there is no "push" you must wait for a request so timing out has to be "silent".
One doubt here regarding uWebsockets (feel free to correct me here),
If a client sends a request, and we know in the framework that an unhandled error has occurred - why not send a response with 500
(or appropriate status code) instead of waiting and timing out. Also in the current logic, on client sending a request and an unhandled error occurs - the client is already waiting for a response - would it be possible to send a timeout response here (since client has initiated the request already and there is no server independently pushing data here).
Aha, the timeouts I talk about are the general way "any unhandled error" is caught. But the point of timeouts are not for a request that was made but never responded to, but rather as keep-alive timeout. But in any case - adding an error here will fix this.
It really is just this fix https://github.com/uNetworking/uWebSockets/commit/388e2b3364ffcd4bc2c57a73166ecfde8fc1875d
Here is output:
* Mark bundle as not supporting multiuse
< HTTP/1.1 431 Request Header Fields Too Large
< Connection: close
<
* Closing connection 0
<h1>Request Header Fields Too Large</h1><hr><i>uWebSockets/20 Server</i>
👍
@uNetworkingAB That's great, thanks for this!
Just one suggestion here, can we include what exactly was breached i.e <h1>Request Header Fields Too Large (count)</h1><hr><i>uWebSockets/20 Server</i>
or is that too much information for the client.
The reason for this is that for requests which are responded by uWebsockets.js directly - the application code won't be able to record this (correct me if there is a way - I do not see this in the docs). I understand having this setup to inform the application might be a design decision (could be a performance hit) which requires further thinking, but for now the above would help. Let me know
Instead of having a palette of errors it can be a palette of functions returning the error. But this would need more than just you wanting it ;)
Got it, I understand 👍
Hey,
We see that there are two variables that dictate header limits:
When
UWS_HTTP_MAX_HEADERS_SIZE
is breached, the uWebsockets.js app (v20.48.0
) returns a431
within milliseconds (for a request header just above the limit), as expected, and closes the connection. But whenUWS_HTTP_MAX_HEADERS_COUNT
is breached, the app doesn't respond for 8-10 seconds and then sends empty response & closes the connection without returning a4xx
, This causes reverse proxy (NGINX) to return 502s.This seems problematic as a bad client request (with too many headers) results in a 5xx instead of a 4xx and takes a few seconds to reply instead of being instant (on local experimentation, it seems to not be affecting other valid requests sent - but on a large scale, we are not sure if it affects others). I see other consumers that have faced similar issue (Ref)
Steps to replicate: server
Version:
github:uNetworking/uWebSockets.js#v20.48.0
request
Output: