Skip to content

Commit

Permalink
set timeout to telemetry (aptos-labs#8647)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmigo authored and xbtmatt committed Jul 25, 2023
1 parent 05ec3e4 commit 3f5e1e7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crates/aptos/src/common/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use std::{
str::FromStr,
time::{Duration, Instant, SystemTime},
};
use tokio::time::timeout;

/// Prompts for confirmation until a yes or no is given explicitly
pub fn prompt_yes(prompt: &str) -> bool {
Expand Down Expand Up @@ -81,7 +82,15 @@ pub async fn to_common_result<T: Serialize>(
} else {
None
};
send_telemetry_event(command, latency, !is_err, error).await;

if let Err(err) = timeout(
Duration::from_millis(2000),
send_telemetry_event(command, latency, !is_err, error),
)
.await
{
debug!("send_telemetry_event timeout from CLI: {}", err.to_string())
}
}

let result: ResultWrapper<T> = result.into();
Expand Down

0 comments on commit 3f5e1e7

Please sign in to comment.