From c42a40a5b76dac2b11a7b4acb0ad0236c5eb2c5b Mon Sep 17 00:00:00 2001 From: Alexander Lyon Date: Fri, 3 May 2024 15:18:26 +0100 Subject: [PATCH] yield a different warning when the cache upload times out --- crates/turborepo-cache/src/http.rs | 22 ++++++++++++++++++---- crates/turborepo-cache/src/lib.rs | 4 ++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/crates/turborepo-cache/src/http.rs b/crates/turborepo-cache/src/http.rs index 9253c5cad1efb..510fa1e8ee795 100644 --- a/crates/turborepo-cache/src/http.rs +++ b/crates/turborepo-cache/src/http.rs @@ -75,7 +75,10 @@ impl HTTPCache { .map(|signer| signer.generate_tag(hash.as_bytes(), &artifact_body)) .transpose()?; - self.client + tracing::debug!("uploading {}", hash); + + match self + .client .put_artifact( hash, &artifact_body, @@ -85,9 +88,20 @@ impl HTTPCache { self.api_auth.team_id.as_deref(), self.api_auth.team_slug.as_deref(), ) - .await?; - - Ok(()) + .await + { + Ok(_) => { + tracing::debug!("uploaded {}", hash); + Ok(()) + } + Err(turborepo_api_client::Error::ReqwestError(e)) if e.is_timeout() => { + Err(CacheError::TimeoutError(hash.to_string())) + } + Err(turborepo_api_client::Error::ReqwestError(e)) if e.is_connect() => { + Err(CacheError::ConnectError) + } + Err(e) => Err(e.into()), + } } #[tracing::instrument(skip_all)] diff --git a/crates/turborepo-cache/src/lib.rs b/crates/turborepo-cache/src/lib.rs index 36423adda1dc8..0f9fbd00de00d 100644 --- a/crates/turborepo-cache/src/lib.rs +++ b/crates/turborepo-cache/src/lib.rs @@ -44,6 +44,10 @@ pub enum CacheError { InvalidFilePath(String, #[backtrace] Backtrace), #[error("failed to contact remote cache: {0}")] ApiClientError(Box, #[backtrace] Backtrace), + #[error("the cache artifact for {0} was too large to upload within the timeout")] + TimeoutError(String), + #[error("could not connect to the cache")] + ConnectError, #[error("signing artifact failed: {0}")] SignatureError(#[from] SignatureError, #[backtrace] Backtrace), #[error("invalid duration")]