Repository navigation
Stop polling response bodies after client disconnect - #3023
Closed
behnam-oneschema wants to merge 1 commit into
Closed
behnam-oneschema wants to merge 1 commit into
behnam-oneschema wants to merge 1 commit into
Conversation
Previously, while waiting for the next response body item, Rocket did not observe that Hyper had dropped the body's receiver. A body reader that stalled was thus retained and polled after its client was gone: an HTTP/1.1 connection that closed or an HTTP/2 stream whose response was dropped left the reader alive until the server shut down. This commit also waits on the body channel's closure, preferring ready body items so that EOF and reader error handling are unchanged. When the receiver closes first, the response ends with a 'BrokenPipe' error and the body, including its reader, is dropped. Fixes rwf2#3022. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Member
|
Merged in 10fe7ef. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #3022.
While
_send_responsewaits for the next item from the response body stream, it now also waits for Hyper to drop the body's receiver:Previously, a body reader that stalled was kept and polled after the client was gone. Rocket would only notice when the reader produced another item and the send failed, and a reader that never produced one stayed alive until shutdown.
biasedorder checks the reader first. Data, EOF, and reader errors that are ready are handled exactly as before, so the error propagation from 1269fc3 is unchanged. Only a reader that is pending when the receiver closes is cut short.send_responsereturnsBrokenPipe, which it already logs as "Remote left: …". It doesn't log "Response succeeded."Tests
The new
core/lib/tests/response-cancellation.rslaunches a real server on 127.0.0.1. Its route streamshelloand then stalls, and the test checks that the reader is dropped within 2 seconds:http1_disconnect_drops_stalled_reader: a raw TCP client reads the status line andhello, then closes the socket.http2_reset_drops_stalled_reader(#[cfg(feature = "http2")]): a Hyper prior-knowledge HTTP/2 client receiveshelloand drops the response while keeping the connection open. A second request on the same connection then succeeds.Both tests time out without the
server.rschange and pass with it. These also pass:--features http2,--no-default-features(HTTP/1.1 test only),--test response-framing, and./scripts/test.sh --core(all 8 feature configurations).