Skip to content
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

Fix timeouts causing unexplained EOFs #246

Merged
merged 2 commits into from
Nov 2, 2020
Merged

Conversation

sagebind
Copy link
Owner

@sagebind sagebind commented Nov 1, 2020

If a request errors after the response headers have already been received, but the full response body has not been read yet, then the response body stream will begin returning EOF without any other explanation other than what is written to the logger. This gives the appearance that everything is fine but half of the response body is missing.

To fix this, be sure to communicate to the response stream when a transfer error occurs while streaming the response body, so that the next call to read from the response will return an appropriate error instead of an unexplained EOF.

This is especially an obvious problem when combined with the timeout option, which can very likely occur during reading of the response body, whereas most other errors are likely to occur before that time.

First raised in #154.

If a request errors after the response headers have already been received, but the full response body has not been read yet, then the response body stream will begin returning EOF without any other explanation other than what is written to the logger. This gives the appearance that everything is fine but half of the response body is missing.

To fix this, be sure to communicate to the response stream when a transfer error occurs while streaming the response body, so that the next call to read from the response will return an appropriate error instead of an unexplained EOF.

This is especially an obvious problem when combined with the timeout option, which can very likely occur during reading of the response body, whereas most other errors are likely to occur before that time.

See #154.
@sagebind sagebind added the bug Something is borken label Nov 1, 2020
@codecov
Copy link

codecov bot commented Nov 1, 2020

Codecov Report

Merging #246 into master will increase coverage by 0.26%.
The diff coverage is 81.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #246      +/-   ##
==========================================
+ Coverage   71.98%   72.24%   +0.26%     
==========================================
  Files          48       48              
  Lines        2406     2425      +19     
==========================================
+ Hits         1732     1752      +20     
+ Misses        674      673       -1     
Impacted Files Coverage Δ
src/error.rs 27.71% <0.00%> (+4.81%) ⬆️
testserver/src/lib.rs 100.00% <ø> (ø)
testserver/src/mock.rs 80.00% <0.00%> (-1.09%) ⬇️
src/handler.rs 71.37% <83.33%> (ø)
testserver/src/response.rs 88.46% <87.50%> (-11.54%) ⬇️
tests/timeouts.rs 87.50% <100.00%> (+12.50%) ⬆️
src/response.rs 82.35% <0.00%> (+7.35%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e7c8c68...6bed8fa. Read the comment docs.

@sagebind sagebind merged commit b9581a3 into master Nov 2, 2020
@sagebind sagebind deleted the 154-read-response-timeout branch November 2, 2020 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is borken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant