Skip to content

Commit

Permalink
fix(evm): reduce web3 request timeout to 20s (#1973)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamardy authored Sep 28, 2023
1 parent 6370fa5 commit 2ce6e4a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions mm2src/coins/eth/web3_transport/http_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::eth::{web3_transport::Web3SendOut, EthCoin, GuiAuthMessages, RpcTrans
use common::APPLICATION_JSON;
use futures::lock::Mutex as AsyncMutex;
use http::header::CONTENT_TYPE;
use jsonrpc_core::{Call, Response};
use jsonrpc_core::{Call, Id, Response};
use mm2_net::transport::{GuiAuthValidation, GuiAuthValidationGenerator};
use serde_json::Value as Json;
#[cfg(not(target_arch = "wasm32"))] use std::ops::Deref;
Expand Down Expand Up @@ -183,7 +183,7 @@ async fn send_request(
use http::header::HeaderValue;
use mm2_net::transport::slurp_req;

const REQUEST_TIMEOUT_S: f64 = 60.;
const REQUEST_TIMEOUT_S: f64 = 20.;

let mut errors = Vec::new();

Expand Down Expand Up @@ -215,9 +215,14 @@ async fn send_request(
let res = match rc {
Either::Left((r, _t)) => r,
Either::Right((_t, _r)) => {
let (method, id) = match &request {
Call::MethodCall(m) => (m.method.clone(), m.id.clone()),
Call::Notification(n) => (n.method.clone(), Id::Null),
Call::Invalid { id } => ("Invalid call".to_string(), id.clone()),
};
let error = format!(
"Error requesting '{}': {}s timeout expired",
node.uri, REQUEST_TIMEOUT_S
"Error requesting '{}': {}s timeout expired, method: '{}', id: {:?}",
node.uri, REQUEST_TIMEOUT_S, method, id
);
warn!("{}", error);
errors.push(Web3RpcError::Transport(error));
Expand Down

0 comments on commit 2ce6e4a

Please sign in to comment.