diff --git a/test/cli/run/esm-bug-leak-fixture.mjs b/test/cli/run/esm-bug-leak-fixture.mjs index 9884aa394222..294d0b9b5d25 100644 --- a/test/cli/run/esm-bug-leak-fixture.mjs +++ b/test/cli/run/esm-bug-leak-fixture.mjs @@ -1,6 +1,8 @@ import { createRequire } from "node:module"; const require = createRequire(import.meta.url); -const dest = await import.meta.resolve("./esm-leak-fixture-large-ast.mjs"); +// require.cache is keyed by absolute path; the file:// URL import.meta.resolve() +// returns never matches an entry, so deleting it would not evict the module. +const dest = require.resolve("./esm-leak-fixture-large-ast.mjs"); // ASAN's quarantine retains freed allocations (default 256 MB) so RSS deltas // run far higher under bun-asan; widen the threshold to avoid false positives. const isASAN = process.execPath.includes("bun-asan"); @@ -14,6 +16,11 @@ for (let i = 0; i < 5; i++) { delete require.cache[dest]; await import(dest); } +if (!(dest in require.cache)) { + console.log("require.cache has no entry for", dest, "so deleting it never evicts the module"); + console.log("\n--fail--\n"); + process.exit(1); +} if (typeof Bun !== "undefined") Bun.gc(true); const baseline = rss();