From 8769a293bc812ac939a7375af784ff0878e59f84 Mon Sep 17 00:00:00 2001 From: Andrei Eres Date: Mon, 21 Aug 2023 14:25:09 +0200 Subject: [PATCH 1/2] Retry on RPC error --- essentials/src/api/subxt_wrapper.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/essentials/src/api/subxt_wrapper.rs b/essentials/src/api/subxt_wrapper.rs index cfc897f4..b9a60bb0 100644 --- a/essentials/src/api/subxt_wrapper.rs +++ b/essentials/src/api/subxt_wrapper.rs @@ -274,7 +274,9 @@ 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) @@ -282,6 +284,7 @@ impl RequestExecutor { error!("[{}] Subxt error: {:?}", url, e); connection_pool.remove(url); if (retry.sleep().await).is_err() { + error!("Here we throwing errors {}", url); return Err(SubxtWrapperError::Timeout) } } else { From 1af3668c1738babd770079bdb829fbc2783eff6f Mon Sep 17 00:00:00 2001 From: Andrei Eres Date: Mon, 21 Aug 2023 15:34:17 +0200 Subject: [PATCH 2/2] Update --- essentials/src/api/subxt_wrapper.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/essentials/src/api/subxt_wrapper.rs b/essentials/src/api/subxt_wrapper.rs index b9a60bb0..14e7b867 100644 --- a/essentials/src/api/subxt_wrapper.rs +++ b/essentials/src/api/subxt_wrapper.rs @@ -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, @@ -281,10 +281,9 @@ impl RequestExecutor { 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() { - error!("Here we throwing errors {}", url); return Err(SubxtWrapperError::Timeout) } } else {