oven-sh/bun · error · Error
This benchmark needs a GC hook: run with Bun, or node --expo
Error message
This benchmark needs a GC hook: run with Bun, or node --expose-gc.
What it means
Error "This benchmark needs a GC hook: run with Bun, or node --expose-gc." thrown in oven-sh/bun.
Source
Thrown at bench/snippets/webstreams-memory.mjs:5
// Web Streams memory: (1) retained RSS per live instance, (2) peak/settled RSS for
// streaming workloads. Run with any JS runtime; extra heap counts print under Bun.
const N = 100_000;
const gc = globalThis.Bun?.gc ?? globalThis.gc;
if (!gc) throw new Error("This benchmark needs a GC hook: run with Bun, or node --expose-gc.");
const rss = () => process.memoryUsage.rss();
const MB = 1024 * 1024;
const fmt = n => (n / MB).toFixed(1).padStart(8) + " MB";
console.log(`# per-instance retained RSS (n=${N} live instances)`);
const keep = [];
function perInstance(label, make) {
gc(true);
const before = rss();
const held = new Array(N);
for (let i = 0; i < N; i++) held[i] = make();
gc(true);
const perObject = (rss() - before) / N;
console.log(`${label.padEnd(40)} ${perObject.toFixed(0).padStart(6)} bytes/instance`);
keep.push(held);
}
perInstance("new ReadableStream({pull(){}})", () => new ReadableStream({ pull() {} }));
perInstance("new ReadableStream() + getReader()", () => new ReadableStream({ pull() {} }).getReader());View on GitHub (pinned to 8c5296ac45)
When it happens
Trigger: Thrown at bench/snippets/webstreams-memory.mjs:5 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/ab85ed31068cfd57.
Report an issue: GitHub.