Skip to content

test(crawler): store-scripts memory assertion measures retained heap after a forced GC #1384 - #1393

Closed
nc9 wants to merge 2 commits into
mainfrom
fix/store-scripts-gc-flake-1384
Closed

nc9 wants to merge 2 commits into
mainfrom
fix/store-scripts-gc-flake-1384

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #1384.

The "many 5 MB bundles" test read process.memoryUsage().heapUsed before and after the storage call with no collection, so it counted whatever garbage the runtime had not swept (106 MB once, in the release gate, against a 64 MiB bound).

  • New retainedHeapBytes(fn) in store-scripts-1255.test.ts: two forced full collections (Bun.gc(true)), baseline, run, two more collections, delta. It measures what is retained, not what is awaiting a sweep.
  • The assertion keeps its meaning (the storage call retains none of the 200 MB it was handed) with a 32 MiB bound; measured retained heap is 16 to 19 KB across runs (the fake store's repeated-string bodies sit outside heapUsed), so the margin is large.
  • New test: the measure catches a deliberately leaky store (8 private Buffer copies of every body it is given): retained is over 32 MiB, so the test would fail if the storage call retained bodies.
  • 10 consecutive runs of the file, with retention-289-288.test.ts in the same process and two CPU burners running, all pass. Not run: the whole crawler suite 10 times (one heavy process per lane).

Test-only: no docs, no CHANGELOG entry. Skill: no change needed.

nik

@nc9 nc9 mentioned this pull request Oct 31, 2026
@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.147 as fd9a338c 631654e7 via #1412. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.147. Closing this original.

nik

@nc9 nc9 closed this Oct 31, 2026
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.

tests: store-scripts-1255 heap assertion is GC-timing dependent and failed the release gate

1 participant