fix: eof hanging bodies on streamed requests #3718
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3715
Not convinced this is a perfect fix so open to suggestions and feedback here. The docs tests seem to be failing on my fork of master here as well so I don't think it's anything I've done here.
There's no tests for this because I cannot for the life of me find a way to reproduce this with a test harness. But #3715 provides a functioning example of the bug.
Description
This PR introduces a fix for a a timeout issue with streaming proxies like Traefik.
The bug occurs when a client sends an invalid request to the server as a multipart TCP packet. Actix may be able to detect that the request will not succeed, for example due to an invalid header against a request that requires a body, the server will then respond immediately to the client while leaving the body bytes unread. When a second request is made, those body bytes are then read as the first part of the message, causing the server to block until it hits its own timeout threshold, since they can't be parsed as a valid message.
This fix forces a eof to be sent in cases where the request will not receive further processing but bytes remain unread from that request.