Skip to content

Fix flaky metadata timer test#7213

Merged
gonzaloriestra merged 1 commit intomainfrom
river-fix-flaky-metadata-timer-test
Apr 7, 2026
Merged

Fix flaky metadata timer test#7213
gonzaloriestra merged 1 commit intomainfrom
river-fix-flaky-metadata-timer-test

Conversation

@gonzaloriestra
Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

The nested timer tests compared performance timing values using exact equality via toMatchObject. Due to floating-point arithmetic precision, values like a + b can differ from separately measured durations by tiny amounts (e.g. 11.820208999999977 vs 11.82020900000009), causing intermittent failures.

Failure example:

FAIL   @shopify/cli-kit  src/public/node/metadata.test.ts > runtime metadata > can handle when a nested timer fails
      Tests  1 failed | 4188 passed | 4 skipped (4193)
AssertionError: expected { …(4) } to match object { 'a#wall': 24.639792000000057, …(3) }
   Start at  09:26:53

   Duration  326.04s (transform 12.87s, setup 5.60s, collect 473.62s, tests 54.49s, environment 11.66s, prepare 28.83s)
- Expected

+ Received


Error: AssertionError: expected { …(4) } to match object { 'a#wall': 24.639792000000057, …(3) }

- Expected
+ Received

  {
-   "a#measurable": 11.820208999999977,
+   "a#measurable": 11.82020900000009,
    "a#wall": 24.639792000000057,
    "b#measurable": 12.81958300000008,
    "b#wall": 12.81958300000008,
  }

 ❯ src/public/node/metadata.test.ts:165:21


  {
-   "a#measurable": 11.820208999999977,
+   "a#measurable": 11.82020900000009,
    "a#wall": 24.639792000000057,
    "b#measurable": 12.81958300000008,
    "b#wall": 12.81958300000008,
  }

WHAT is this pull request doing?

Replace exact equality with expect.closeTo(value, 5) which tolerates differences smaller than 1e-5 — more than sufficient for millisecond-level timing measurements.

How to test your changes?

CI

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

…parisons

The nested timer tests compared performance timing values using exact equality
via toMatchObject. Due to floating-point arithmetic precision, values like
`a + b` can differ from separately measured durations by tiny amounts
(e.g. 11.820208999999977 vs 11.82020900000009), causing intermittent failures.

Replace exact equality with expect.closeTo(value, 5) which tolerates
differences smaller than 1e-5 — more than sufficient for millisecond-level
timing measurements.
@gonzaloriestra gonzaloriestra marked this pull request as ready for review April 7, 2026 09:54
@gonzaloriestra gonzaloriestra requested a review from a team as a code owner April 7, 2026 09:54
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

Copy link
Copy Markdown
Contributor Author

gonzaloriestra commented Apr 7, 2026

Merge activity

  • Apr 7, 12:32 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 7, 12:33 PM UTC: @gonzaloriestra added this pull request to the GitHub merge queue with Graphite.

@gonzaloriestra gonzaloriestra added this pull request to the merge queue Apr 7, 2026
Merged via the queue into main with commit 2901820 Apr 7, 2026
26 of 27 checks passed
@gonzaloriestra gonzaloriestra deleted the river-fix-flaky-metadata-timer-test branch April 7, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants