Skip to content

Commit

Permalink
Auto merge of #697 - Mark-Simulacrum:skip-panic, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Avoid panicking on negative durations

This currently causes a panic when loading a run's details page after it has finished the initial processing (but not yet completed log uploads, I think?).
  • Loading branch information
bors committed Jun 4, 2023
2 parents 365c12f + 2f13d9f commit 48c666a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ impl Crater {
fn workspace(&self, docker_env: Option<&str>, fast_init: bool) -> Result<Workspace, Error> {
let mut builder = WorkspaceBuilder::new(&crater::dirs::WORK_DIR, &crater::USER_AGENT)
.fast_init(fast_init)
.fetch_registry_index_during_builds(false)
.fetch_registry_index_during_builds(true)
.command_timeout(Some(Duration::from_secs(15 * 60)))
.command_no_output_timeout(Some(Duration::from_secs(5 * 60)))
.running_inside_docker(std::env::var("CRATER_INSIDE_DOCKER").is_ok());
Expand Down
8 changes: 7 additions & 1 deletion src/server/routes/ui/experiments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ struct ExperimentContext {
}

fn humanize(duration: Duration) -> String {
let duration = duration.to_std().expect("non-negative duration");
let duration = match duration.to_std() {
Ok(d) => d,
Err(_) => {
// Don't try to make it pretty as a fallback.
return format!("{:?}", duration);
}
};
if duration.as_secs() < 60 {
format!("{duration:?}")
} else if duration.as_secs() < 60 * 60 {
Expand Down

0 comments on commit 48c666a

Please sign in to comment.