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 3, 2023
2 parents 365c12f + 7379810 commit e4849d8
Showing 1 changed file with 7 additions and 1 deletion.
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 e4849d8

Please sign in to comment.