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")]