Repository navigation
test(http): speed up and de-flake serve-async-stream-client-abort.test.ts - #35919
Conversation
…t.ts The three tests each spawn an independent fixture subprocess; running them concurrently overlaps the debug/ASAN startup instead of paying it three times in series. The native-stream fixture spawned three more bun-debug children just to get a stalled stdout pipe, which under ASAN is ~1.5 s of startup each. cat with a piped stdin is the same native-source ReadableStream without the JS runtime boot (Windows keeps a bun child since cat is posix-only and there is no ASAN lane there). The error-stream fixture raced Bun.sleep(1) against the server seeing the client's RST, so the first abort iteration intermittently reported the late enqueue as "ok" instead of the expected closed-controller error. Waiting on req.signal's abort event makes the sequencing deterministic. Assertions now parse the fixture JSON and check the actual fields (lateCloseResults contents, aborted/completed counts) rather than scanning for an ok:true substring.
|
Warning Review limit reached
Next review available in: 12 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
Comment |
|
Updated 8:27 AM PT - Jul 26th, 2026
❌ @robobun, your commit f73ce7d has 1 failures in
Add 🧪 To try this PR locally: bunx bun-pr 35919That installs a local version of the PR into your bun-35919 --bun |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
LGTM — test-only speedup and de-flake, no production code touched.
What was reviewed:
test.concurrentis safe: each fixture owns an independent subprocess with its ownport: 0server.- error-stream:
once(s, "data")still rejects on pre-data socket errors; the post-RSTerrorswallow only covers the client-side ECONNRESET fromresetAndDestroy().currentSignalis set infetch()beforeerror()'s pull resolvesstarted, so no ordering race. - native-stream: the removed 30s child backstop is replaced by pipe-EOF — when the parent dies,
cat/process.stdin.pipe(process.stdout)see stdin close and exit, so no orphans on a crashed run. The Response body is still a subprocess stdout pipe, so the native-sourceReadableStreamUAF path is unchanged. - New
completed + aborted === 600assertion matches the unmodified async-stream fixture'sWORKERS * ITERATIONS.
Extended reasoning...
Overview
Touches three test files only: serve-async-stream-client-abort.test.ts and two of its fixtures. Converts the three tests to test.concurrent, extracts a shared runFixture helper, replaces expect.stringContaining('"ok":true') with parsed-JSON assertions, swaps the native-stream fixture's stalled child from a nested bun-debug to cat (posix) / process.stdin.pipe(process.stdout) (win32), and replaces the error-stream fixture's Bun.sleep(1) race with an await on req.signal's abort event.
Security risks
None. Test-only; no new external inputs, no network beyond loopback, no new dependencies.
Level of scrutiny
Low-to-moderate. No runtime code changes. The main risk with test speedup/de-flake PRs is silently weakening coverage, so I checked each change against that:
- Concurrency: fixtures are hermetic subprocesses — no shared state.
catswap: the property under test is "client abort while a native-source ReadableStream (subprocess stdout pipe) has a pull in flight". Any subprocess stdout pipe exercises that path; the child's runtime is irrelevant. Windows keeps a bun child so no reliance on a posix binary there.req.signalawait: this is the repo-recommended "await the actual observable condition" pattern replacing a 1 ms sleep. It strictly tightens the sequencing the original test intended.- Assertions: strictly stronger than before (exact
lateCloseResultsshape,aborted: 3,completed + aborted === 600). Verified the unmodifiedserve-async-stream-client-abort-fixture.tsemits{ok, completed, aborted}with 20×30 iterations.
Other factors
- The removed 30 s backstop timer in the old bun child is no longer needed: both
catand the win32 stdin-pipe child exit on stdin EOF when the parent dies, so orphans are still prevented on a crashed run. once()fromnode:eventson anAbortSignal(EventTarget) andchild.stdin.flush()on a spawn FileSink are both established patterns elsewhere intest/.s.on("error", () => {})looks like a swallow but only covers the expected client-side ECONNRESET afterresetAndDestroy();once(s, "data")still rejects on a genuine pre-data connection error via its internal error listener.- No prior human reviews; CI build was still running at review time.
|
CI finished: Ready for review. |
* upstream/main: (422 commits) install: drop packages held only by optional-peer resolution slots from bun.lock (oven-sh#35681) Update mimalloc to the upstream dev3 (v3.4.3) sync (oven-sh#36431) compile(pe): ftruncate the Windows --compile output after writing (oven-sh#36430) Strong: back bun_jsc::Strong with StrongRootBlock; free AbortSignal.timeout at wrapper GC (oven-sh#35849) test(harness): replace toRun matcher with async bunRun + toSpawn (oven-sh#36424) test: measure memory via harness rss() instead of process.memoryUsage.rss() (oven-sh#36429) Deflake a few tests no-orphans(windows): allow CREATE_BREAKAWAY_FROM_JOB and set DIE_ON_UNHANDLED_EXCEPTION on the Job (oven-sh#36414) GarbageCollectionController: replace per-tick heap sampler with idle timer only (oven-sh#35356) exe_format(pe): write a valid OptionalHeader.CheckSum for --compile output (oven-sh#36383) FileSink: flush buffered bytes when process.exit() runs in the same tick as write() (oven-sh#36250) test(http): speed up and de-flake serve-async-stream-client-abort.test.ts (oven-sh#35919) test(20144): stop racing child startup against the 1s SIGKILL guard (oven-sh#34166) test(no-orphans): skip fast-exit perl daemon test on macOS (oven-sh#36413) fs: return negative BigIntStats *Ns for pre-epoch timestamps (oven-sh#36187) event_loop: make DeferredTaskQueue::run tolerate re-entrant map mutation (oven-sh#32703) dotenv: stop panicking on nested `${...}` inside `${VAR:-default}` (oven-sh#36199) fetch: make the idle timer an absolute deadline for the response header block (oven-sh#36145) bundler: don't panic on unterminated naming template placeholders (oven-sh#36325) Buffer#indexOf/lastIndexOf: rare-byte SIMD filter with a Two-Way O(n+m) fallback (oven-sh#36420) ... # Conflicts: # src/jsc/bindings/BunDebugger.cpp
* upstream/main: (422 commits) install: drop packages held only by optional-peer resolution slots from bun.lock (oven-sh#35681) Update mimalloc to the upstream dev3 (v3.4.3) sync (oven-sh#36431) compile(pe): ftruncate the Windows --compile output after writing (oven-sh#36430) Strong: back bun_jsc::Strong with StrongRootBlock; free AbortSignal.timeout at wrapper GC (oven-sh#35849) test(harness): replace toRun matcher with async bunRun + toSpawn (oven-sh#36424) test: measure memory via harness rss() instead of process.memoryUsage.rss() (oven-sh#36429) Deflake a few tests no-orphans(windows): allow CREATE_BREAKAWAY_FROM_JOB and set DIE_ON_UNHANDLED_EXCEPTION on the Job (oven-sh#36414) GarbageCollectionController: replace per-tick heap sampler with idle timer only (oven-sh#35356) exe_format(pe): write a valid OptionalHeader.CheckSum for --compile output (oven-sh#36383) FileSink: flush buffered bytes when process.exit() runs in the same tick as write() (oven-sh#36250) test(http): speed up and de-flake serve-async-stream-client-abort.test.ts (oven-sh#35919) test(20144): stop racing child startup against the 1s SIGKILL guard (oven-sh#34166) test(no-orphans): skip fast-exit perl daemon test on macOS (oven-sh#36413) fs: return negative BigIntStats *Ns for pre-epoch timestamps (oven-sh#36187) event_loop: make DeferredTaskQueue::run tolerate re-entrant map mutation (oven-sh#32703) dotenv: stop panicking on nested `${...}` inside `${VAR:-default}` (oven-sh#36199) fetch: make the idle timer an absolute deadline for the response header block (oven-sh#36145) bundler: don't panic on unterminated naming template placeholders (oven-sh#36325) Buffer#indexOf/lastIndexOf: rare-byte SIMD filter with a Two-Way O(n+m) fallback (oven-sh#36420) ...
* upstream/main: (422 commits) install: drop packages held only by optional-peer resolution slots from bun.lock (oven-sh#35681) Update mimalloc to the upstream dev3 (v3.4.3) sync (oven-sh#36431) compile(pe): ftruncate the Windows --compile output after writing (oven-sh#36430) Strong: back bun_jsc::Strong with StrongRootBlock; free AbortSignal.timeout at wrapper GC (oven-sh#35849) test(harness): replace toRun matcher with async bunRun + toSpawn (oven-sh#36424) test: measure memory via harness rss() instead of process.memoryUsage.rss() (oven-sh#36429) Deflake a few tests no-orphans(windows): allow CREATE_BREAKAWAY_FROM_JOB and set DIE_ON_UNHANDLED_EXCEPTION on the Job (oven-sh#36414) GarbageCollectionController: replace per-tick heap sampler with idle timer only (oven-sh#35356) exe_format(pe): write a valid OptionalHeader.CheckSum for --compile output (oven-sh#36383) FileSink: flush buffered bytes when process.exit() runs in the same tick as write() (oven-sh#36250) test(http): speed up and de-flake serve-async-stream-client-abort.test.ts (oven-sh#35919) test(20144): stop racing child startup against the 1s SIGKILL guard (oven-sh#34166) test(no-orphans): skip fast-exit perl daemon test on macOS (oven-sh#36413) fs: return negative BigIntStats *Ns for pre-epoch timestamps (oven-sh#36187) event_loop: make DeferredTaskQueue::run tolerate re-entrant map mutation (oven-sh#32703) dotenv: stop panicking on nested `${...}` inside `${VAR:-default}` (oven-sh#36199) fetch: make the idle timer an absolute deadline for the response header block (oven-sh#36145) bundler: don't panic on unterminated naming template placeholders (oven-sh#36325) Buffer#indexOf/lastIndexOf: rare-byte SIMD filter with a Two-Way O(n+m) fallback (oven-sh#36420) ... # Conflicts: # src/js/internal/debugger.ts
* upstream/main: (422 commits) install: drop packages held only by optional-peer resolution slots from bun.lock (oven-sh#35681) Update mimalloc to the upstream dev3 (v3.4.3) sync (oven-sh#36431) compile(pe): ftruncate the Windows --compile output after writing (oven-sh#36430) Strong: back bun_jsc::Strong with StrongRootBlock; free AbortSignal.timeout at wrapper GC (oven-sh#35849) test(harness): replace toRun matcher with async bunRun + toSpawn (oven-sh#36424) test: measure memory via harness rss() instead of process.memoryUsage.rss() (oven-sh#36429) Deflake a few tests no-orphans(windows): allow CREATE_BREAKAWAY_FROM_JOB and set DIE_ON_UNHANDLED_EXCEPTION on the Job (oven-sh#36414) GarbageCollectionController: replace per-tick heap sampler with idle timer only (oven-sh#35356) exe_format(pe): write a valid OptionalHeader.CheckSum for --compile output (oven-sh#36383) FileSink: flush buffered bytes when process.exit() runs in the same tick as write() (oven-sh#36250) test(http): speed up and de-flake serve-async-stream-client-abort.test.ts (oven-sh#35919) test(20144): stop racing child startup against the 1s SIGKILL guard (oven-sh#34166) test(no-orphans): skip fast-exit perl daemon test on macOS (oven-sh#36413) fs: return negative BigIntStats *Ns for pre-epoch timestamps (oven-sh#36187) event_loop: make DeferredTaskQueue::run tolerate re-entrant map mutation (oven-sh#32703) dotenv: stop panicking on nested `${...}` inside `${VAR:-default}` (oven-sh#36199) fetch: make the idle timer an absolute deadline for the response header block (oven-sh#36145) bundler: don't panic on unterminated naming template placeholders (oven-sh#36325) Buffer#indexOf/lastIndexOf: rare-byte SIMD filter with a Two-Way O(n+m) fallback (oven-sh#36420) ...
What
Cuts
test/js/bun/http/serve-async-stream-client-abort.test.tsfrom ~14 s to ~6 s under debug+ASAN and fixes a pre-existing ~30% flake in the error-stream fixture.Why it was slow
The file runs three tests, each spawning a fixture subprocess. Under debug+ASAN a
bun-debugstartup is ~1.5 s, and the native-stream fixture spawns three morebun-debugchildren just to obtain a stalled stdout pipe. That is six ASAN startups in series.Changes
port: 0server, so there is no shared state.catfor the stalled child on posix. The test only needs a subprocess stdout pipe (native-sourceReadableStream) that emits one byte and then blocks.catwith a piped stdin is that, without a JS runtime boot per iteration. Windows keeps a bun child (process.stdin.pipe(process.stdout)): there is nocatthere and no ASAN lane, so startup cost is not the bottleneck. Fixture time under ASAN: 4.2 s → 0.5 s.req.signalinstead ofBun.sleep(1). The abort-path loop released the parked producer afterresetAndDestroy()plus a 1 ms sleep and hoped the server had processed the RST by then. On a loaded box the first iteration's lateenqueue()often landed on a still-live sink and reported"ok"instead of the expected closed-controller error (4/30 solo runs, 5/15 runs of the unmodified test file on current main).req.signal'sabortevent is the server-side observation point, so the driver now awaits it before releasing: 0/40 solo runs, 0/20 full-file runs after.lateCloseResultsentries,aborted/completedcounts,aborted: 3) instead ofexpect.stringContaining('"ok":true'), and assertsstderr/exitCode/signalCodeseparately so a failure names the field.Coverage
No tests removed or skipped. Iteration counts are unchanged. The native-stream repro mechanism is unchanged: the Response body is still a subprocess stdout pipe, which is the native-source
ReadableStreampath the original UAF was on.Timing (local, debug+ASAN)
[stamp-90s] gate passed · iteration 0 · 3 files touched
passes on PR (with fix)
diff hotspot
gate history · 1 passed · 0 rejected · iteration 0
evidence per changed file
self-review · no surviving concerns
29 concerns were raised and did not survive verification.