blob: 7379b1b7b733b5234839b8d3c57165b149d68dfb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import { heapStats } from "bun:jsc";
const { SERVER } = process.env;
if (typeof SERVER === "undefined" || !SERVER?.length) {
throw new Error("SERVER environment variable is not set");
}
const COUNT = parseInt(process.env.COUNT || "20", 10);
var oks = 0;
await (async function runAll() {
for (let j = 0; j < COUNT; j++) {
oks += (await fetch(SERVER)).ok;
}
})();
if (oks !== COUNT) {
throw new Error("Not all requests succeeded");
}
await Bun.sleep(10);
Bun.gc(true);
if ((heapStats().objectTypeCounts.Response ?? 0) > 5) {
throw new Error("Too many Response objects: " + heapStats().objectTypeCounts.Response);
}
|