Skip to content

fix(core): avoid printing 60.0s in build time logs - #8552

Merged
chenjiahan merged 1 commit into
web-infra-dev:mainfrom
kwy404:fix-build-time-rounding
Sep 26, 2026
Merged

chenjiahan merged 1 commit into
web-infra-dev:mainfrom
kwy404:fix-build-time-rounding

Conversation

@kwy404

@kwy404 kwy404 commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Motivation

prettyTime does the < 60 check and the minutes and seconds split on the raw value, and only rounds at the end with toFixed(1). When the seconds part is 59.95 or more it rounds up to 60.0 without carrying into the minutes, so a 119.96s build is logged as built in 1m 60.0s. Below one minute, 59.96s is printed as 60.0s.

Changes

Round the time to one decimal place first, then use that value for the < 60 check and the split. Now 119.96s is printed as 2m and 59.96s as 1m. Since the whole second check also sees the rounded value, 60.04s now prints 1m instead of 1m 0.0s. The existing test cases keep the same output.

Added two cases to the existing prettyTime test in packages/core/tests/helpers.test.ts. Before the fix it fails with expected '60.0s' to deeply equal '1m' (and prettyTime(119.96) returns 1m 60.0s). After the fix the test passes, along with the rest of the core unit tests.

@chenjiahan chenjiahan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@chenjiahan
chenjiahan merged commit 16ff6d9 into web-infra-dev:main Sep 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants