Skip to content

Commit

Permalink
Merge pull request #504 from paritytech/AndreiEres/retry-on-rpc-error
Browse files Browse the repository at this point in the history
Retry on RPC error
  • Loading branch information
AndreiEres authored Aug 21, 2023
2 parents 1e8d8ca + 1af3668 commit 102030a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions essentials/src/api/subxt_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
types::{AccountId32, BlockNumber, ClaimQueue, CoreOccupied, SessionKeys, Timestamp, H256},
utils::{Retry, RetryOptions},
};
use log::error;
use log::{error, warn};
use std::{
collections::{hash_map::HashMap, BTreeMap},
fmt::Debug,
Expand Down Expand Up @@ -274,12 +274,14 @@ impl RequestExecutor {
if let Err(e) = reply {
let need_to_retry = matches!(
e,
SubxtWrapperError::SubxtError(subxt::Error::Io(_)) | SubxtWrapperError::NoResponseFromDynamicApi(_)
SubxtWrapperError::SubxtError(subxt::Error::Io(_)) |
SubxtWrapperError::SubxtError(subxt::Error::Rpc(_)) |
SubxtWrapperError::NoResponseFromDynamicApi(_)
);
if !need_to_retry {
return Err(e)
}
error!("[{}] Subxt error: {:?}", url, e);
warn!("[{}] Subxt error: {:?}", url, e);
connection_pool.remove(url);
if (retry.sleep().await).is_err() {
return Err(SubxtWrapperError::Timeout)
Expand Down

0 comments on commit 102030a

Please sign in to comment.