aboutsummaryrefslogtreecommitdiff
path: root/test/js/web/fetch/fetch-leak-test-fixture-2.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/js/web/fetch/fetch-leak-test-fixture-2.js')
-rw-r--r--test/js/web/fetch/fetch-leak-test-fixture-2.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/js/web/fetch/fetch-leak-test-fixture-2.js b/test/js/web/fetch/fetch-leak-test-fixture-2.js
new file mode 100644
index 000000000..7379b1b7b
--- /dev/null
+++ b/test/js/web/fetch/fetch-leak-test-fixture-2.js
@@ -0,0 +1,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);
+}