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
Setting first_data_timeout triggers an H18 error on Heroku #2539
Comments
Here are the latest logs that have H18 errors. They all get serviced in about 5 seconds which corresponds to the value I set for
|
I was thinking if H18 and H27 happens at the same time (have the same |
We've currently written the code so that if the client has sent nothing or has sent an incomplete request, we do not write a 408. If the client has written a complete request, we will write a 408. I think this is actually the exact opposite of what it should be:
I'm not sure what we should do if a |
This should be a pretty simple test to write, btw. |
I tested this one and reproduced the H18 error. However with some debugging I added, I saw that puma returns a 408 error to heroku so I don't understand why the H18 error is still here 🤷♂️ |
Here is the code's current 408-sending behavior: Lines 213 to 216 in 366496b
Lines 107 to 109 in 366496b
This is my interpretation:
Related 503-sending behavior:
So I think Puma is behaving how we expect (responding with 408 if a request times out when sending a long POST body). I don't know why Heroku is turning the 408 responses into H18/503. One guess is that Heroku has hard-coded 'request-then-response' logic that doesn't properly handle any 'interrupt response' that closes the socket before a full request body is received (even though it's 'correct' HTTP)? I would be interested in whether the same H18 error could be triggered on Heroku if a 413 Payload Too Large error is returned by an application to interrupt POST requests that are too big. |
Note issue #2574 may also be in play here - since v5.0.3, the |
I've examined https://devcenter.heroku.com/articles/http-routing but I can't really spot any clues about what we are seeing here
I tried this, with
Interestingly, after
cc @schneems do you have more info about the Heroku router internals? or who the people to ping would be? |
Scratch that, H18 is logged. H13 was me doing this too quickly and not adding 413 the |
I found a StackOverflow answer that confirmed the Heroku issue with support, and it matches my initial guess:
So Puma could theoretically implement a 'Heroku-H18 workaround' option that keeps reading the complete request body even if a 4xx error response is returned before the request completes, but that would defeat the purpose of the 4xx error interrupting the request (which is to prevent unnecessary data from being transferred in the first place). So I think the current behavior is fine from Puma's perspective, and this bug is pretty clearly Heroku's responsibility to fix. |
Closing as "not our problem": if you believe differently, please continue the discussion. |
If I set the
first_data_timeout
config to a value lower than 30 seconds, the connection is closed correctly if no data has been received. However an H18 error still gets triggered by Heroku. If I understand this correctly, the desired behaviour should be to return an HTTP 408 error.I'm using the latest version of Puma (5.1.1) and here is the Heroku metrics graph showing that H18n errors are triggered after about 5 seconds:
This is also discussed on Stack Overflow.
The text was updated successfully, but these errors were encountered: