| 1 | // @effect-diagnostics nodeBuiltinImport:off - memory assertions run in an isolated Node process with explicit GC. |
| 2 | import * as NodeChildProcess from "node:child_process"; |
| 3 | import * as NodeURL from "node:url"; |
| 4 | import * as NodeUtil from "node:util"; |
| 5 | import { expect, it } from "vite-plus/test"; |
| 6 | |
| 7 | const execFile = NodeUtil.promisify(NodeChildProcess.execFile); |
| 8 | |
| 9 | it("releases traced results while cached lookup fibers remain alive", async () => { |
| 10 | const root = NodeURL.fileURLToPath(new URL("../../../", import.meta.url)); |
| 11 | const fixture = NodeURL.fileURLToPath( |
| 12 | new URL("./testing/TraceRetention.fixture.mjs", import.meta.url), |
| 13 | ); |
| 14 | const { stdout } = await execFile(process.execPath, ["--expose-gc", fixture, root]); |
| 15 | const result = JSON.parse(stdout) as { cacheSize: number; retained: number; exported: number }; |
| 16 | expect(result.cacheSize).toBe(4); |
| 17 | expect(result.exported).toBe(4); |
| 18 | expect(result.retained).toBe(0); |
| 19 | }); |