save last provider error

This commit is contained in:
Bryan Stitt 2023-06-26 23:04:56 -07:00
parent 917dfc914f
commit b35ad330c9
2 changed files with 10 additions and 1 deletions

@ -1739,7 +1739,7 @@ impl Web3ProxyApp {
}).await? }).await?
} else { } else {
let x = timeout( let x = timeout(
max_wait + Duration::from_millis(10), max_wait + Duration::from_millis(100),
self.balanced_rpcs self.balanced_rpcs
.try_proxy_connection::<_, Arc<RawValue>>( .try_proxy_connection::<_, Arc<RawValue>>(
method, method,

@ -907,6 +907,8 @@ impl Web3Rpcs {
// set error_handler to Save. this might be overridden depending on the request_metadata.authorization // set error_handler to Save. this might be overridden depending on the request_metadata.authorization
let error_handler = Some(RequestErrorHandler::Save); 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 // TODO: the loop here feels somewhat redundant with the loop in best_available_rpc
loop { loop {
if let Some(max_wait) = max_wait { if let Some(max_wait) = max_wait {
@ -969,6 +971,9 @@ impl Web3Rpcs {
Ok(x) => x, Ok(x) => x,
Err(err) => { Err(err) => {
warn!(?err, "error from {}", rpc); warn!(?err, "error from {}", rpc);
last_provider_error = Some(error);
continue; continue;
} }
}; };
@ -1119,6 +1124,10 @@ impl Web3Rpcs {
return Err(err.into()); return Err(err.into());
} }
if let Some(err) = last_provider_error {
return Err(err.into());
}
let num_conns = self.len(); let num_conns = self.len();
let num_skipped = skip_rpcs.len(); let num_skipped = skip_rpcs.len();