From b35ad330c9f0ba8f3fc67ad5bc78e79ef209a313 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Mon, 26 Jun 2023 23:04:56 -0700 Subject: [PATCH] save last provider error --- web3_proxy/src/app/mod.rs | 2 +- web3_proxy/src/rpcs/many.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/web3_proxy/src/app/mod.rs b/web3_proxy/src/app/mod.rs index d882631e..ce43a2df 100644 --- a/web3_proxy/src/app/mod.rs +++ b/web3_proxy/src/app/mod.rs @@ -1739,7 +1739,7 @@ impl Web3ProxyApp { }).await? } else { let x = timeout( - max_wait + Duration::from_millis(10), + max_wait + Duration::from_millis(100), self.balanced_rpcs .try_proxy_connection::<_, Arc>( method, diff --git a/web3_proxy/src/rpcs/many.rs b/web3_proxy/src/rpcs/many.rs index efb12821..6a737a4e 100644 --- a/web3_proxy/src/rpcs/many.rs +++ b/web3_proxy/src/rpcs/many.rs @@ -907,6 +907,8 @@ impl Web3Rpcs { // set error_handler to Save. this might be overridden depending on the request_metadata.authorization let error_handler = Some(RequestErrorHandler::Save); + let mut last_provider_error = None; + // TODO: the loop here feels somewhat redundant with the loop in best_available_rpc loop { if let Some(max_wait) = max_wait { @@ -969,6 +971,9 @@ impl Web3Rpcs { Ok(x) => x, Err(err) => { warn!(?err, "error from {}", rpc); + + last_provider_error = Some(error); + continue; } }; @@ -1119,6 +1124,10 @@ impl Web3Rpcs { return Err(err.into()); } + if let Some(err) = last_provider_error { + return Err(err.into()); + } + let num_conns = self.len(); let num_skipped = skip_rpcs.len();