From 3f5e1e7332180acdc9add94d62fdf2158b4eb355 Mon Sep 17 00:00:00 2001 From: Jin <128556004+0xjinn@users.noreply.github.com> Date: Tue, 13 Jun 2023 18:01:44 -0700 Subject: [PATCH] set timeout to telemetry (#8647) --- crates/aptos/src/common/utils.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/aptos/src/common/utils.rs b/crates/aptos/src/common/utils.rs index 8bacbd1b4d849..0a9c766ff3074 100644 --- a/crates/aptos/src/common/utils.rs +++ b/crates/aptos/src/common/utils.rs @@ -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 { @@ -81,7 +82,15 @@ pub async fn to_common_result( } 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 = result.into();