Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(evm): reduce web3 request timeout to 20s #1973

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading