Skip to content

Commit

Permalink
yield a different warning when the cache upload times out
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed May 7, 2024
1 parent 8558b2b commit 5be570d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 18 additions & 4 deletions crates/turborepo-cache/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)]
Expand Down
4 changes: 4 additions & 0 deletions crates/turborepo-cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ pub enum CacheError {
InvalidFilePath(String, #[backtrace] Backtrace),
#[error("failed to contact remote cache: {0}")]
ApiClientError(Box<turborepo_api_client::Error>, #[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")]
Expand Down

0 comments on commit 5be570d

Please sign in to comment.