From 426da5234bc7db36bb9abb4966df5cd01543bedf Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sat, 25 Jul 2026 15:56:07 +0000 Subject: [PATCH 1/3] test: stop serve-reused-response subprocess inheriting LSan (26s -> ~2s on ASAN CI) On the x64-asan CI lane, scripts/runner.node.mjs sets ASAN_OPTIONS=...detect_leaks=1 and BUN_DESTRUCT_VM_ON_EXIT=1 for the test process. bunEnv spreads process.env, so the spawned subprocess in the "without an error handler" case inherited both and spent ~24s doing a leak scan at exit (Buildkite timestamps show the first 6 in-process tests finish in 690ms, the 7th in 24.2s). Override detect_leaks=0 and BUN_DESTRUCT_VM_ON_EXIT=0 for that spawn: it is a behavior probe (500 + stderr + exit 1), not a leak test, and the outer test process still runs under LSan. Also run the describe block concurrently so the in-process cases overlap the spawn, and assert the static-route case never invokes error(). Local debug+ASAN with the CI runner env (detect_leaks=1, GC level 1, integrity audit 1.0, exception checks, VM destruct): before: 9.22s 9.44s 9.64s 9.27s 9.82s (avg 9.48s) after: 4.24s 5.10s 4.02s 4.20s 3.26s (avg 4.16s) --- test/js/bun/http/serve-reused-response.test.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test/js/bun/http/serve-reused-response.test.ts b/test/js/bun/http/serve-reused-response.test.ts index eeb89f4185be..6c8787df8839 100644 --- a/test/js/bun/http/serve-reused-response.test.ts +++ b/test/js/bun/http/serve-reused-response.test.ts @@ -5,7 +5,9 @@ import { bunEnv, bunExe } from "harness"; // A fetch handler that returns a Response whose body has already been used // (most often the same Response object returned for every request) must invoke // the error handler instead of silently sending a 200 with an empty body. -describe("returning a Response with an already-used body", () => { +// Every case spins up its own port-0 server and shares no state, so the whole +// block runs concurrently to keep wall time bounded by the single subprocess spawn. +describe.concurrent("returning a Response with an already-used body", () => { const alreadyUsedError = { code: "ERR_BODY_ALREADY_USED", name: "TypeError", @@ -102,6 +104,7 @@ describe("returning a Response with an already-used body", () => { it("a Response reused through a static route keeps working", async () => { // Static routes snapshot the body at registration, so reuse is allowed there. + const error = jest.fn(); await using server = serve({ port: 0, routes: { @@ -110,6 +113,7 @@ describe("returning a Response with an already-used body", () => { fetch() { return new Response("fallback"); }, + error, }); for (let i = 0; i < 3; i++) { @@ -117,6 +121,7 @@ describe("returning a Response with an already-used body", () => { expect(await response.text()).toBe("static-body"); expect(response.status).toBe(200); } + expect(error).not.toHaveBeenCalled(); }); it("without an error handler, logs the error and responds with 500", async () => { @@ -138,7 +143,15 @@ describe("returning a Response with an already-used body", () => { console.log(second.status, JSON.stringify(await second.text())); server.stop(true);`, ], - env: bunEnv, + env: { + ...bunEnv, + // On the ASAN CI lane this file runs with detect_leaks=1 and + // BUN_DESTRUCT_VM_ON_EXIT=1, which bunEnv forwards via process.env. That + // turns this behavior probe into a ~24s leak scan. Disable leak detection + // for the subprocess; the outer test process still runs under LSan. + ASAN_OPTIONS: [bunEnv.ASAN_OPTIONS, "detect_leaks=0"].filter(Boolean).join(":"), + BUN_DESTRUCT_VM_ON_EXIT: "0", + }, stdout: "pipe", stderr: "pipe", }); From 98a9d266fd749da8acf5909ed86b0b0c7d0ee89f Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sat, 25 Jul 2026 16:50:35 +0000 Subject: [PATCH 2/3] drop BUN_DESTRUCT_VM_ON_EXIT override; detect_leaks=0 alone carries the win The cited precedents (bun-server.test.ts, websocket-server-upgrade-reentrant.test.ts) only override ASAN_OPTIONS. Isolated timing of the spawned -e script under the CI env: 8.25s with detect_leaks=1, 1.09s with detect_leaks=0 alone, 0.77s with detect_leaks=0 + DESTRUCT_VM=0. The extra ~300ms is not worth introducing the repo's only DESTRUCT_VM=0 line and losing VM-teardown crash coverage in the subprocess. --- test/js/bun/http/serve-reused-response.test.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/js/bun/http/serve-reused-response.test.ts b/test/js/bun/http/serve-reused-response.test.ts index 6c8787df8839..96a16d3186da 100644 --- a/test/js/bun/http/serve-reused-response.test.ts +++ b/test/js/bun/http/serve-reused-response.test.ts @@ -145,12 +145,10 @@ describe.concurrent("returning a Response with an already-used body", () => { ], env: { ...bunEnv, - // On the ASAN CI lane this file runs with detect_leaks=1 and - // BUN_DESTRUCT_VM_ON_EXIT=1, which bunEnv forwards via process.env. That - // turns this behavior probe into a ~24s leak scan. Disable leak detection - // for the subprocess; the outer test process still runs under LSan. + // On the ASAN CI lane bunEnv forwards detect_leaks=1 via process.env, + // turning this behavior probe into a ~24s leak scan at exit. Disable leak + // detection for the subprocess; the outer test process still runs under LSan. ASAN_OPTIONS: [bunEnv.ASAN_OPTIONS, "detect_leaks=0"].filter(Boolean).join(":"), - BUN_DESTRUCT_VM_ON_EXIT: "0", }, stdout: "pipe", stderr: "pipe", From ba44a3a3e8dd30f746952c6b18484ad3f21cf171 Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Sat, 25 Jul 2026 21:09:48 +0000 Subject: [PATCH 3/3] ci: retrigger