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

fix(error): detect timeouts wrapped in body decode errors#3064
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
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