Skip to content

Commit 13d2df2

Browse files
committed
fix(client): update errors before checking if retries exhuasted
This fixes an issue where we failed to include the latest error in the `errors` vec before returning from impl_inner_call with Error::AllAttemptsErrored. This meant that if the configured retries was set to 0, an error would be raised with an empty errors vec. Tested by setting Config::retry to 0, triggering a client-side error, and observing the errors vec contained within Error::AllAttemptsErrored.
1 parent 5d7be37 commit 13d2df2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ macro_rules! impl_inner_call {
5555
Err(e) => {
5656
let failed_attempts = errors.len() + 1;
5757

58+
warn!("call '{}' failed with {}, retry: {}/{}", stringify!($name), e, failed_attempts, $self.config.retry());
59+
60+
errors.push(e);
61+
5862
if retries_exhausted(failed_attempts, $self.config.retry()) {
5963
warn!("call '{}' failed after {} attempts", stringify!($name), failed_attempts);
6064
return Err(Error::AllAttemptsErrored(errors));
6165
}
6266

63-
warn!("call '{}' failed with {}, retry: {}/{}", stringify!($name), e, failed_attempts, $self.config.retry());
64-
65-
errors.push(e);
66-
6767
// Only one thread will try to recreate the client getting the write lock,
6868
// other eventual threads will get Err and will block at the beginning of
6969
// previous loop when trying to read()

0 commit comments

Comments
 (0)