Skip to content

Commit

Permalink
[cli] Increase REST endpoint timeout to 30s (#4628)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
igor-aptos authored Sep 29, 2022
1 parent 9ce07ce commit 3bb7c35
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions crates/aptos/src/common/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -798,11 +799,18 @@ pub struct RestOptions {
/// Defaults to <https://fullnode.devnet.aptoslabs.com/v1>
#[clap(long)]
pub(crate) url: Option<reqwest::Url>,

/// 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<reqwest::Url>) -> Self {
RestOptions { url }
pub fn new(url: Option<reqwest::Url>, connection_timeout_s: Option<u64>) -> Self {
RestOptions {
url,
connection_timeout_s: connection_timeout_s.unwrap_or(30),
}
}

/// Retrieve the URL from the profile or the command line
Expand All @@ -823,7 +831,10 @@ impl RestOptions {
}

pub fn client(&self, profile: &str) -> CliTypedResult<Client> {
Ok(Client::new(self.url(profile)?))
Ok(Client::new_with_timeout(
self.url(profile)?,
Duration::from_secs(self.connection_timeout_s),
))
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/aptos/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3bb7c35

Please sign in to comment.