Skip to content

fix(core): error when restoring http cache with no outputs #30961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions packages/nx/src/native/cache/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,26 @@ impl NxCache {
&outputs_path,
&self.workspace_root
);
let sz = _copy(outputs_path, &self.workspace_root)?;
let sz = _copy(outputs_path, &self.workspace_root);

Ok(sz)
match sz {
Err(e) => {
let kind = underlying_io_error_kind(&e);
match kind {
Some(std::io::ErrorKind::NotFound) => {
trace!("No artifacts to copy: {:?}", e);
Ok(0)
}
_ => {
return Err(anyhow::anyhow!("Error copying files from cache: {:?}", e));
}
}
}
Ok(sz) => {
trace!("Copied {} bytes from cache", sz);
Ok(sz)
}
}
}

#[napi]
Expand Down Expand Up @@ -407,3 +424,13 @@ where
}
}
}

// From: https://docs.rs/anyhow/latest/anyhow/struct.Error.html#example-1
fn underlying_io_error_kind(error: &anyhow::Error) -> Option<std::io::ErrorKind> {
for cause in error.chain() {
if let Some(io_error) = cause.downcast_ref::<std::io::Error>() {
return Some(io_error.kind());
}
}
None
}
Loading