Skip to content

fix(error): detect timeouts wrapped in body decode errors - #3064

Merged
seanmonstar merged 1 commit into
seanmonstar:masterfrom
raphaelroshan:fix-2839-body-timeout-error
Jul 13, 2026
Merged

seanmonstar merged 1 commit into
seanmonstar:masterfrom
raphaelroshan:fix-2839-body-timeout-error

Conversation

@raphaelroshan

@raphaelroshan raphaelroshan commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2839.

When a read or total timeout fires while streaming the response body, the error is wrapped as a decode error (Kind::Decode), so is_timeout() didn't report it even though a timeout was the underlying cause — and is_decode() was true with the message "error decoding response body", which is misleading.

Per review feedback, this keeps the decode kind (the error did happen while decoding the body) and instead makes is_timeout() recurse into a nested reqwest::Error while walking the source chain. So a timeout wrapped in a decode error is now correctly reported by is_timeout(), while is_decode() stays true.

Added unit tests covering a body timeout wrapped by decode (both is_decode() and is_timeout() are true) and that an unrelated decode error is not a timeout.

@seanmonstar

Copy link
Copy Markdown
Owner

Thanks for the PR!

I kind of feel like it should still wrap the error in "decode", because the error happened while decoding the body. An alternative would be to just make is_timeout search the source chain for the timeout marker, perhaps?

@raphaelroshan

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback, let me see how i can improve this!

@raphaelroshan
raphaelroshan marked this pull request as ready for review July 6, 2026 07:04
When a read/total timeout fired while streaming the response body, the
error is wrapped as a decode error (Kind::Decode), so is_timeout() did not
report it even though a timeout was the underlying cause.

Make is_timeout() also recurse into a nested reqwest::Error while walking
the source chain, so a timeout wrapped in a decode error is still detected.
The error keeps its decode kind (it did happen while decoding the body).

Closes seanmonstar#2839
@raphaelroshan
raphaelroshan force-pushed the fix-2839-body-timeout-error branch from 10e301a to 5446168 Compare July 8, 2026 13:42
@raphaelroshan raphaelroshan changed the title fix(error): preserve timeout kind for response body timeouts fix(error): detect timeouts wrapped in body decode errors Jul 8, 2026
@raphaelroshan

Copy link
Copy Markdown
Contributor Author

@seanmonstar I've updated it based on your feedback, its now a small change touching is_timeout(). Updated the tests as well

@seanmonstar seanmonstar left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@seanmonstar
seanmonstar merged commit 99996a1 into seanmonstar:master Jul 13, 2026
137 of 156 checks passed
kodiakhq Bot pushed a commit to pdylanross/fatigue that referenced this pull request Sep 14, 2026
Bumps reqwest from 0.13.4 to 0.13.5.

Release notes
Sourced from reqwest's releases.

v0.13.5
tl;dr

Add Error::is_dns() to identify errors caused by DNS resolution failures.
Add ClientBuilder::http1_max_headers(usize) to configure the maximum number of headers accepted in an HTTP/1 response (default 100).
Add TLS version to TlsInfo extension.
Fix hickory-dns feature to use Ipv6AndIpv4 strategy to prefer IPv6.
Fix sending wrong proxy-auth if multiple proxies intercept a given URL.

What's Changed

fix(blocking): preserve version and extensions in TryFromhttp::Request by @​wwhsaber in seanmonstar/reqwest#3050
Remove unnecessary clones by @​FranciscoTGouveia in seanmonstar/reqwest#3052
Add Referrer and Referrer Policy methods to WASM Request API by @​Billy-Sheppard in seanmonstar/reqwest#3049
chore(deps): bump actions/checkout from 6 to 7 by @​dependabot[bot] in seanmonstar/reqwest#3058
feat: add Error::is_dns() to identify DNS resolution failures by @​JoakoI98 in seanmonstar/reqwest#3057
Fix blocking client timeout panic by @​V-Mann-Nick in seanmonstar/reqwest#3060
Use LookupIpStrategy::Ipv6AndIpv4 to actually prefer IPv6 when using hickory-dns by @​FalkWoldmann in seanmonstar/reqwest#3063
feat: Add ClientBuilder::http1_max_headers by @​smaeda-ks in seanmonstar/reqwest#3065
feat: expose the negotiated TLS version via TlsInfo by @​dennisameling in seanmonstar/reqwest#3067
fix(error): detect timeouts wrapped in body decode errors by @​raphaelroshan in seanmonstar/reqwest#3064
Remove unnecessary clones and a cast by @​FranciscoTGouveia in seanmonstar/reqwest#3071
chore(deps): upgrade base64 to 0.23 by @​paolobarbolini in seanmonstar/reqwest#3074
perf(body): reuse tokio::time::Sleep timer via reset() in ReadTimeoutBody by @​spellsaif in seanmonstar/reqwest#3085
fix(cookie): avoid cloning store and url on Poll::Pending in ResponseFuture::poll by @​spellsaif in seanmonstar/reqwest#3084
src/async_impl/request.rs_improved_doc_for_json_fn: by @​Athleteg in seanmonstar/reqwest#3082
fix: proxy could use wrong credentials if many matched by @​seanmonstar in seanmonstar/reqwest#3098

New Contributors

@​wwhsaber made their first contribution in seanmonstar/reqwest#3050
@​FranciscoTGouveia made their first contribution in seanmonstar/reqwest#3052
@​Billy-Sheppard made their first contribution in seanmonstar/reqwest#3049
@​JoakoI98 made their first contribution in seanmonstar/reqwest#3057
@​V-Mann-Nick made their first contribution in seanmonstar/reqwest#3060
@​FalkWoldmann made their first contribution in seanmonstar/reqwest#3063
@​smaeda-ks made their first contribution in seanmonstar/reqwest#3065
@​raphaelroshan made their first contribution in seanmonstar/reqwest#3064
@​spellsaif made their first contribution in seanmonstar/reqwest#3085
@​Athleteg made their first contribution in seanmonstar/reqwest#3082

Full Changelog: seanmonstar/reqwest@v0.13.4...v0.13.5



Changelog
Sourced from reqwest's changelog.

v0.13.5

Add Error::is_dns() to identify errors caused by DNS resolution failures.
Add ClientBuilder::http1_max_headers(usize) to configure the maximum number of headers accepted in an HTTP/1 response (default 100).
Add TLS version to TlsInfo extension.
Fix hickory-dns feature to use Ipv6AndIpv4 strategy to prefer IPv6.
Fix sending wrong proxy-auth if multiple proxies intercept a given URL.




Commits

de55373 v0.13.5
4d3fe12 fix: proxy could use wrong credentials if many matched (#3098)
9f06fd2 docs: improve description of JSON method (#3082)
5bdb2f0 perf(cookie): avoid cloning store and url on Poll::Pending in ResponseFuture:...
ffda263 perf(body): reuse tokio::time::Sleep timer via reset() in ReadTimeoutBody (#3...
4e9a3c7 chore: add pull request template for human-written content
17e9bcb chore(deps): upgrade base64 to 0.23 (#3074)
221abe9 chore: Remove unnecessary clones and a cast (#3071)
99996a1 fix(error): detect timeouts wrapped in body decode errors (#3064)
fc99bd5 feat: expose the negotiated TLS version via TlsInfo (#3067)
Additional commits viewable in compare view




Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

@dependabot rebase will rebase this PR
@dependabot recreate will recreate this PR, overwriting any edits that have been made to it
@dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
@dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
@dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Body timeout errors incorrectly reported as "error decoding response body"

2 participants