Skip to content

Commit 1df72ee

Browse files
authored
fix: handle NaN in build time estimate (#5679)
1 parent c0d9e32 commit 1df72ee

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

site/src/components/WorkspaceBuildProgress/WorkspaceBuildProgress.stories.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,9 @@ StartingHighVariaton.args = {
6767
...Starting.args,
6868
transitionStats: { P50: 10000, P95: 20000 },
6969
}
70+
71+
export const StartingZeroEstimate = Template.bind({})
72+
StartingZeroEstimate.args = {
73+
...Starting.args,
74+
transitionStats: { P50: 0, P95: 0 },
75+
}

site/src/components/WorkspaceBuildProgress/WorkspaceBuildProgress.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ const estimateFinish = (
3434
p95: number,
3535
): [number | undefined, string] => {
3636
const sinceStart = dayjs().diff(startedAt)
37-
const secondsLeft = (est: number) =>
38-
Math.max(
37+
const secondsLeft = (est: number) => {
38+
const max = Math.max(
3939
Math.ceil(dayjs.duration((1 - sinceStart / est) * est).asSeconds()),
4040
0,
4141
)
42+
return isNaN(max) ? 0 : max
43+
}
4244

4345
const lowGuess = secondsLeft(p50)
4446
const highGuess = secondsLeft(p95)

0 commit comments

Comments
 (0)