From 3bb7c3504a353dfc450a2fa0db76699dd5d096ca Mon Sep 17 00:00:00 2001 From: igor-aptos <110557261+igor-aptos@users.noreply.github.com> Date: Thu, 29 Sep 2022 14:40:26 -0700 Subject: [PATCH] [cli] Increase REST endpoint timeout to 30s (#4628) We saw bunch of timeouts with 10s timeout during loadtests, and then the experience is confusing - transcation actually goes through, but that is not clear --- crates/aptos/src/common/types.rs | 17 ++++++++++++++--- crates/aptos/src/test/mod.rs | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/crates/aptos/src/common/types.rs b/crates/aptos/src/common/types.rs index ae4b1c5f1680a..282af20008e6e 100644 --- a/crates/aptos/src/common/types.rs +++ b/crates/aptos/src/common/types.rs @@ -37,6 +37,7 @@ use serde::{Deserialize, Serialize}; use std::convert::TryFrom; #[cfg(unix)] use std::os::unix::fs::OpenOptionsExt; +use std::time::Duration; use std::{ collections::BTreeMap, fmt::{Debug, Display, Formatter}, @@ -798,11 +799,18 @@ pub struct RestOptions { /// Defaults to #[clap(long)] pub(crate) url: Option, + + /// Connection timeout in seconds, used for the REST endpoint of the fullnode + #[clap(long, default_value = "30")] + pub connection_timeout_s: u64, } impl RestOptions { - pub fn new(url: Option) -> Self { - RestOptions { url } + pub fn new(url: Option, connection_timeout_s: Option) -> Self { + RestOptions { + url, + connection_timeout_s: connection_timeout_s.unwrap_or(30), + } } /// Retrieve the URL from the profile or the command line @@ -823,7 +831,10 @@ impl RestOptions { } pub fn client(&self, profile: &str) -> CliTypedResult { - Ok(Client::new(self.url(profile)?)) + Ok(Client::new_with_timeout( + self.url(profile)?, + Duration::from_secs(self.connection_timeout_s), + )) } } diff --git a/crates/aptos/src/test/mod.rs b/crates/aptos/src/test/mod.rs index b1856b9d87f09..29d702c7060a9 100644 --- a/crates/aptos/src/test/mod.rs +++ b/crates/aptos/src/test/mod.rs @@ -910,7 +910,7 @@ impl CliTestFramework { } pub fn rest_options(&self) -> RestOptions { - RestOptions::new(Some(self.endpoint.clone())) + RestOptions::new(Some(self.endpoint.clone()), None) } pub fn faucet_options(&self) -> FaucetOptions {