-
Notifications
You must be signed in to change notification settings - Fork 5.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
Panic on aborted requests to properly close the connection #11129
Panic on aborted requests to properly close the connection #11129
Conversation
Hello @tonybart1337, Thanks for investigating this and opening this PR! I don't think raising a panic is the best solution in that case. Would you be incline to rework the PR in that direction? |
Hi @rtribotte. Thank you for taking your time on this PR. I think it only lacks a few lines of code and this is a pretty serious bug |
Hello @tonybart1337, It is up to you, but the simplest way would that we push review commits to show the approach I was thinking of, it is always easier to demonstrate directly with code, WDYT? |
@tonybart1337 I can open a PR on your branch to demonstrate the approach, but the changes must be first rebased on branch v2.11, as this is a bug fix. Thanks! |
0a589bd
to
1de55db
Compare
I'll share what I come up with in a few hours today Looks like github button didn't rebase properly, I'll force push the fix as well |
0642d6c
to
4d6cb6a
Compare
@rtribotte rebased + implemented the wrapper still not sure on how to properly close the connection, doesn't panic already handle it for us? |
@tonybart1337 Thanks! I think panics should be reserved for cases where the state is unexpected or irrecoverable, and here it seems possible to properly handle the response or close the connection. |
45b9178
to
933536c
Compare
@rtribotte please lmk if I can help somehow, I totally agree that panics should be used as the last resort, but since it gets the job done and closes the connection properly, maybe we should merge it to fix the issue and then you can implement a proper solution without a panic? this issue can lead to serious consequences like caching invalid data and serving it to the end users, or serving incomplete data while the end users will have no idea why this happened, or even worse if they have no means to check the validity of the data received in most cases I believe that users will get an immediate error when they try to decode their binary data, like an image, for example, or maybe most users don't use "transfer-encoding: chunked" at all, otherwise I don't know how to explain why this is not fixed yet |
Hello @tonybart1337, Actually, I think you are right about reflecting the panic, this let the net/http server handle the response abortion. |
Thanks @tonybart1337 for merging the PR, we will leave the waiting for fixes label until the unit tests are fixed and a new one is introduced for this new behavior. |
Hello @tonybart1337, Are you still willing to work on this pull request and address @rtribotte's changes, or do you want us to push some commits? |
Hi @kevinpollet . If you could implement the tests yourselves that would be great, I don't have a lot of spare time at the moment 😞 |
c8ef92e
to
ea78d51
Compare
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.
Thanks 👍
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.
Thanks!
ffc7f17
to
3e3d1f4
Compare
3e3d1f4
to
2fdd7a5
Compare
What does this PR do?
Fixes this issue
Might also fix this one. I tested it on HTTP/2 as well
Motivation
It breaks caching on our servers and many other things because we receive truncated data
Additional Notes
Client sends a HTTP/1.1 request to the server and downloads a file which is dynamically generated and returned in chunks, but sometimes the connection might abort midway and instead of aborting the connection traefik sends zero length chunk finalizing the request and the client ends up receiving a truncated response with no way of knowing whether it received the full file or not.