Two tests compare 1 MiB buffers with toEqual and can time out in CI #101

Closed
opened 2026-10-09 16:56:20 -04:00 by goddard · 1 comment
Collaborator

Two tests compare 1 MiB buffers with toEqual. Vitest's deep equality checks them one byte at a time, which takes about 3.6 seconds and leaves each test close to its 5-second timeout. CI run 837 failed this way at 5,570 ms on a commit that only changed DeployServerDialog.svelte.

  • library-metadata.test.ts:31 runs expect(getVersionContent(id)).toEqual(content) on a 1 MiB plugin.
    • The test took 3,561 ms in run 835 and 3,470 ms in run 836, then 5,570 ms in run 837, where it timed out.
    • Locally it takes 3.4–4.5 s, and one of my runs also went over 5 s.
    • Timing each step showed the toEqual line takes about 3.6 s. The 20 inserts take about 2 ms each, and the imports about 0.3 s.
  • file-blobs.test.ts:77-81 compares the 1 MiB blob download with toEqual in the same way. It took 3,658 ms in run 837, so it's the next one likely to time out.

The other buffer toEqual checks in the suite compare only a few bytes.

Fix

  • Compare with Buffer.equals in library-metadata.test.ts:31, e.g. expect(getVersionContent(id)?.equals(content)).toBe(true)
  • Do the same for the download in file-blobs.test.ts:77-81

In a throwaway copy, these two changes cut the tests to about 0.35 s and 0.7 s, and both passed three runs in a row.

Two tests compare 1 MiB buffers with `toEqual`. Vitest's deep equality checks them one byte at a time, which takes about 3.6 seconds and leaves each test close to its 5-second timeout. [CI run 837](https://gitea.thewrightserver.net/josh/electric-cherry/actions/runs/837) failed this way at 5,570 ms on a commit that only changed `DeployServerDialog.svelte`. - `library-metadata.test.ts:31` runs `expect(getVersionContent(id)).toEqual(content)` on a 1 MiB plugin. - The test took 3,561 ms in run 835 and 3,470 ms in run 836, then 5,570 ms in run 837, where it timed out. - Locally it takes 3.4–4.5 s, and one of my runs also went over 5 s. - Timing each step showed the `toEqual` line takes about 3.6 s. The 20 inserts take about 2 ms each, and the imports about 0.3 s. - `file-blobs.test.ts:77-81` compares the 1 MiB blob download with `toEqual` in the same way. It took 3,658 ms in run 837, so it's the next one likely to time out. The other buffer `toEqual` checks in the suite compare only a few bytes. **Fix** - [x] Compare with `Buffer.equals` in `library-metadata.test.ts:31`, e.g. `expect(getVersionContent(id)?.equals(content)).toBe(true)` - [x] Do the same for the download in `file-blobs.test.ts:77-81` In a throwaway copy, these two changes cut the tests to about 0.35 s and 0.7 s, and both passed three runs in a row.
goddard added the
priority
low
type/bug
labels 2026-10-09 16:56:20 -04:00
josh was assigned by goddard 2026-10-09 16:56:20 -04:00
Author
Collaborator

Reviewed 4c1f2cdb8f. Both 1 MiB comparisons now use Buffer.equals, and the two tests are well clear of the timeout, so I'm closing this.

Checklist

  • library-metadata.test.ts:31. It now asserts getVersionContent(id)?.equals(content) is true. The optional chaining still fails the test if the content is missing. The test now takes 469–542 ms locally (it was 3.4–4.5 s) and 453 ms in run 841 (it was 3.5 s and 5.6 s).
  • file-blobs.test.ts:77-81. The blob download is now compared with .equals(content). The test now takes 810–874 ms locally and 387 ms in run 841 (it was 3.7 s).

Review notes

  • Both files pass three runs in a row locally. CI runs 840 and 841 pass the full suite (2,703 and 2,718 tests).
Reviewed 4c1f2cdb8f4d53a42b86a275e6285c94f20e740c. Both 1 MiB comparisons now use `Buffer.equals`, and the two tests are well clear of the timeout, so I'm closing this. **Checklist** - [x] **`library-metadata.test.ts:31`.** It now asserts `getVersionContent(id)?.equals(content)` is `true`. The optional chaining still fails the test if the content is missing. The test now takes 469–542 ms locally (it was 3.4–4.5 s) and 453 ms in [run 841](https://gitea.thewrightserver.net/josh/electric-cherry/actions/runs/841) (it was 3.5 s and 5.6 s). - [x] **`file-blobs.test.ts:77-81`.** The blob download is now compared with `.equals(content)`. The test now takes 810–874 ms locally and 387 ms in run 841 (it was 3.7 s). **Review notes** - Both files pass three runs in a row locally. CI runs [840](https://gitea.thewrightserver.net/josh/electric-cherry/actions/runs/840) and 841 pass the full suite (2,703 and 2,718 tests).
Sign in to join this conversation.