Skip to content

usockets: dispatch the outer ready-poll remainder before a nested tick overwrites it - #32233

Closed
robobun wants to merge 8 commits into
mainfrom
farm/fa66f8b7/usockets-nested-tick-ready-polls
Closed

robobun wants to merge 8 commits into
mainfrom
farm/fa66f8b7/usockets-nested-tick-ready-polls

Conversation

@robobun

@robobun robobun commented Jun 13, 2026 •

Copy link
Copy Markdown
Collaborator

What

Concurrent Bun.$ commands could hang forever: the subprocess exits and is reaped (ps shows nothing), but the command's promise never resolves.

Repro

Concurrency alone is not sufficient: plain concurrent Bun.$ does not hang by itself (0/20 on an unfixed Linux release build, 0/8 on unfixed macOS), and a bare .then chain never re-enters the event loop. The loss needs the interrupted callback, or a continuation it drains inline, to synchronously wait on the event loop, that is, one of the waitForPromise callers: bun:test's async matchers, HTMLRewriter.transform with an async handler, Bun.build plugin callbacks that return promises, macros, the module and entry loaders, bake's render paths, the REPL. That wait re-enters us_loop_run_bun_tick while the outer batch is mid-dispatch.

const cmds = Array.from({ length: 34 }, (_, i) => Bun.$`printf %s out-${i}`.quiet());
// any synchronous event-loop wait in a continuation; HTMLRewriter with an async
// handler is one plain runtime API that does it (bun:test's .resolves is another)
cmds[0].then(() => {
  new HTMLRewriter().on("p", { async element(el) { await Bun.sleep(30); } }).transform("<p>x</p>");
});
await Promise.all(cmds); // hangs: 20/20 unfixed, 0/20 fixed (Linux)

Plain require() of an ordinary module is not a trigger (it resolves inside the task drain without a nested kernel wait), and require() of a module with top-level await is refused, so lazy requires in callbacks do not re-enter either.

Root cause

A shell command resolves only once it has both the process-exit event and the stdout/stderr pipe-EOF events (Cmd::has_finished). The pipe readers register one-shot on every POSIX platform (EPOLLONESHOT on Linux, EV_DISPATCH on kqueue).

The event loop fetches a batch of ready events into the shared loop->ready_polls and iterates it by loop->current_ready_poll. When a poll callback re-enters us_loop_run_bun_tick (observed live as epoll_pwait2 <- us_loop_run_bun_tick <- auto_tick <- wait_for_promise <- ... with loop->data.tick_depth == 2), the nested tick's epoll_wait overwrites loop->ready_polls, num_ready_polls, and current_ready_poll. When the outer dispatch resumes it points at the inner batch, so its remaining events are silently skipped.

For a one-shot fd a skipped event is unrecoverable: epoll_wait already disarmed the fd, and onUpdate (which sets the re-arm flag) never ran, so nothing re-arms it. #30301 fixed this for the Linux pidfd by registering it level-triggered, but noted it "doesn't address the underlying nested-tick ready_polls corruption (which also affects other one-shot FilePoll owners)" and assumed pipes self-heal via EPOLLHUP. They do not. This is not Linux-specific: the pipe readers are one-shot on kqueue too, and on macOS the process-exit watch (EVFILT_PROC) is also still one-shot.

Fix

When us_loop_run_bun_tick detects it is nested inside a mid-iteration dispatch (current_ready_poll < num_ready_polls, never true after a completed dispatch), it dispatches the outer batch's remaining entries before its own epoll_wait/kevent can overwrite them.

Why this is the smallest correct shape:

  • A completed dispatch's postcondition is current_ready_poll == num_ready_polls, which is exactly the state a nested tick leaves behind (and why today's failure is a silent skip rather than a double dispatch). Draining the remainder first makes that end state correct, with no saved state, and it recurses at any depth: a drained callback that re-enters gets its own remainder drained the same way.
  • It does not introduce a new reentrancy class. Every still-ready level-triggered fd in the remainder is already re-reported by the nested epoll_wait and dispatched at the deeper level with the outer callback on the stack; this extends the same treatment to the one-shot entries the kernel can no longer re-report. Callbacks that stop, change, or free a sibling poll are covered by us_internal_loop_update_pending_ready_polls exactly as in a flat dispatch, and closed-socket frees stay deferred to the outermost loop_post because tick_depth is already >= 2 when the drain runs.
  • After draining, the nested tick polls with a zero timeout instead of the one its caller chose before the drained callbacks ran, since one of them may have settled the promise the caller is waiting on.
  • On kqueue the coalescing pass is bounded to [first_index, n) so a pending kevent cannot merge into an already-dispatched slot and get lost.
  • An earlier revision snapshotted and restored the batch instead, which required a cross-language invalidation mechanism purely to defend the snapshot from polls freed during the nested tick. The drain needs none of that, so the final diff is epoll_kqueue.c plus the test.

Verification

test/js/bun/spawn/pipe-reader-nested-tick.test.ts covers three triggers with the same 34-command batch geometry: Bun.$ with a bun:test matcher continuation, Bun.$ with an HTMLRewriter async handler continuation (a contractually synchronous runtime API, so the coverage does not depend on the matcher's blocking behavior), and Bun.spawn pipe readers with an onExit trigger.

unfixed fixed
the test file, Linux bun bd each case hangs and times out 3/3 pass (~0.3-0.4s each)
Bun.$ + Bun.spawn cases, macOS (reviewer) Bun.$ hangs 4/4; Bun.spawn variant wedges the runner 4/4 pass 6/6
no-test-code script: 34 x Bun.$ + HTMLRewriter continuation, 20 cold processes, Linux hangs 20/20 (release) hangs 0/20 (debug)
raw 34 x Bun.$ only, 20 cold processes, Linux 0/20 (does not reproduce without a synchronous wait) 0/20

pidfd-exit-nested-tick.test.ts and the full bunshell.test.ts suite pass against the change (377 pass, 0 fail). The unrelated CI red on this PR is a fleet-wide bake/dev/production.test.ts failure affecting every current PR, tracked in #33214.

…p ticks

A poll callback can re-enter us_loop_run_bun_tick (waitForPromise -> autoTick;
in Bun.$ this happens when finish() runs a command's continuation inline during
the poll dispatch via loop.exit()). The inner tick's epoll_wait/kevent
overwrites the shared loop->ready_polls, num_ready_polls, and current_ready_poll
while the outer us_internal_dispatch_ready_polls is still iterating the batch,
so the outer loop resumes against the inner batch and silently skips its
remaining events.

For one-shot fds a skipped event is unrecoverable: the kernel disarmed the fd
when epoll_wait returned it, and onUpdate never ran to set the re-arm flag. PR
#30301 made the pidfd level-triggered so its dropped events recover on the next
wait, but assumed pipes self-heal via EPOLLHUP. A disarmed EPOLLONESHOT fd
reports nothing, so a batch of concurrent Bun.$ commands could drop one
command's stdout/stderr EOF and hang it forever.

Snapshot the outer batch and its cursor before a nested tick fetches new events,
and restore them afterward, so no one-shot event is lost. A poll freed during a
nested tick is nulled out of the live batch and every saved snapshot, so it is
never re-dispatched from a stale entry; FilePolls route teardown through the new
us_loop_invalidate_ready_poll to get the protection sockets already have via
us_poll_stop/us_poll_change.
@robobun

robobun commented Jun 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

@github-actions

Copy link
Copy Markdown
Contributor

Found 3 issues this PR may fix:

  1. Regression in 1.3.14: deterministic segfault in MicrotaskQueue drain after subprocess ready-poll (works on 1.3.13, still crashes on 1.4.0 canary) #32178 - Segfault in Bun__internal_dispatch_ready_poll during microtask drain with 3 concurrent subprocesses — nested tick corrupting ready-poll state causes dispatch against stale/freed poll pointers
  2. Bun Shell hangs with git show command, spawnSync from node:child_process succeeds #26580 - Bun Shell hangs intermittently with git show in loops on Linux CI — matches pattern of concurrent shell pipe readers losing EPOLLONESHOT events in nested event-loop ticks
  3. Event loop busy-spins at 100% CPU when spawning concurrent bun processes using Ink + fetch (macOS ARM64) #27766 - Event loop busy-spins at 100% CPU when spawning ~20 concurrent bun processes on macOS — kqueue variant of lost poll events from nested tick overwriting ready-poll state

If this is helpful, copy the block below into the PR description to auto-close these issues on merge.

Fixes #32178
Fixes #26580
Fixes #27766

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jun 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Refactors uSockets' ready-poll dispatch to support a starting cursor, allowing nested event loop ticks to flush the outer batch's remaining ready-polls before kernel wait calls overwrite them. Adds tickDepth and pendingReadyPolls metrics to Rust FFI and JS getEventLoopStats, plus a regression test.

Changes

Ready-poll dispatch windowing

Layer / File(s) Summary
Windowed dispatch helper and coalescing bounds
packages/bun-usockets/src/eventing/epoll_kqueue.c
Adds us_internal_dispatch_ready_polls_from(loop, start) internal helper; epoll dispatch and kqueue coalescing/merge/decode passes now operate only within [start, num_ready_polls); existing dispatch function becomes a thin wrapper calling the new helper with start=0.
Nested tick detection and outer batch flush
packages/bun-usockets/src/eventing/epoll_kqueue.c
us_loop_run_bun_tick detects nested re-entry (current_ready_poll < num_ready_polls) and dispatches the outer batch remainder via the windowed helper before the kernel wait overwrites ready_polls.
Tick-depth and pending-poll metrics
src/jsc/event_loop.rs, src/js/internal-for-testing.ts
get_active_tasks allocates for 5 properties and reports tickDepth/pendingReadyPolls (derived from uSockets loop counters, zeroed on Windows); getEventLoopStats's TypeScript return type gains these two fields with documentation.
Nested tick regression test
test/js/bun/spawn/pipe-reader-nested-tick.test.ts
Adds a POSIX-only test spawning 34 quiet Bun.$ commands where the first attaches a .then continuation checking event loop stats to confirm a nested tick occurs, then verifies all commands resolve with correct stdout without dropped pipe EOF events.

Possibly related PRs

  • oven-sh/bun#30301: Addresses the same nested-tick/one-shot event-loss family of issues in the event loop dispatch path, targeting pidfd oneshot exit polling on Linux.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the core fix to drain the outer ready-poll remainder before a nested tick overwrites it.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description clearly explains the change and includes verification details, with extra context beyond the template.

Comment @coderabbitai help to get the list of available commands.

@robobun

robobun commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator Author

Assessment of the three issues the bot flagged. This PR fixes the nested-tick ready_polls corruption: when a poll callback re-enters us_loop_run_bun_tick, the inner epoll_wait/kevent overwrites the shared ready_polls/num_ready_polls/current_ready_poll mid-dispatch. That has two failure modes, a dropped one-shot event (hang) and a resumed dispatch reading a stale/garbage batch entry (crash).

#26580 (shell hangs intermittently, git show, Linux CI, spawnSync works) looks like a direct match when the commands run concurrently: a disarmed EPOLLONESHOT pipe reader whose EOF was dropped hangs with no output, the race is intermittent and load-sensitive (hence more on CI), and spawnSync runs on an isolated loop that never takes this nested path. I could not run the closed-source repro, so I am not auto-closing it, but it is a strong candidate. Worth retesting on a canary that includes this change.

#32178 (deterministic segfault, 3 subprocesses) crashes on exactly the path this PR hardens: Bun__internal_dispatch_ready_poll -> loop.exit() -> drainMicrotasks. The decoded top frame is inside the JSC microtask drain rather than a stale poll re-dispatch, so I cannot confirm this specific crash is the ready_polls corruption from the trace alone, and I could not reproduce the private project. Plausibly the same root cause; the reporter retesting on a build with this change would confirm.

#27766 (100% CPU busy-spin, macOS, ~20 concurrent bun + Ink + fetch) presents as a busy-spin, not a silent hang. A dropped one-shot event (the bug here) produces a stuck reader with no CPU, not a spin, so this looks like a separate macOS/kqueue wakeup-storm issue rather than this one.

Not adding Fixes lines since I could not reproduce any of the three directly; happy to if a maintainer confirms #26580/#32178 against a build with this change.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find any bugs, but this touches the core epoll/kqueue dispatch path and adds heap-allocated state that must stay coherent across nested ticks and C↔Rust struct layouts — worth a human look.

Extended reasoning...

Overview

This PR fixes nested-tick corruption of loop->ready_polls by snapshotting the outer dispatch batch onto a LIFO stack before a re-entrant us_loop_run_bun_tick clobbers it, and restoring it on return. It touches epoll_kqueue.c (snapshot struct, save/restore in us_loop_run_bun_tick, snapshot fixup in us_internal_loop_update_pending_ready_polls, new us_loop_invalidate_ready_poll), adds a field to us_internal_loop_data_t, mirrors that field in the Rust InternalLoopData repr(C) struct, adds a Rust FFI wrapper, wires FilePoll::deinit_possibly_defer to invalidate stale entries, and adds a Linux regression test.

Security risks

None apparent — no parsing, auth, or external input handling. The new heap allocation is bounded by num_ready_polls (≤1024) and freed on the same stack frame's exit path.

Level of scrutiny

High. This is the innermost event-loop dispatch path that every poll-driven I/O operation in Bun flows through. Subtle mistakes here manifest as hangs, double-dispatch, or use-after-free across the entire runtime. Specific areas I'd want a human to confirm: (1) the snapshot is taken before tick_depth++'s effects but the restore happens after us_internal_drain_ready_polls, which itself loops and rewrites ready_polls — restoring the outer cursor over whatever drain left behind looks correct but is non-obvious; (2) on kqueue the restored batch re-runs the first-pass coalescing in the outer us_internal_dispatch_ready_polls, which already completed before the nested tick — actually it doesn't, since the outer dispatch resumes mid-second-pass with the snapshot's events but the stack-local coalesced[] array from before the nested call; (3) the C struct gained a trailing void* after int tick_depth, and the Rust mirror must match padding exactly for the PosixLoop offset assertions to hold.

Other factors

CI showed build-rust failures on macOS x64 and aarch64-musl for the pre-autofix commit; the autofix commit may or may not have resolved them. The change is well-documented and includes a targeted regression test, but the blast radius (every nested-tick scenario on every POSIX platform) and the cross-language struct layout coupling put it well outside what I'd approve without human review.

@robobun

robobun commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks, addressing the three points for a human reviewer:

Restore ordering (after us_internal_drain_ready_polls). The nested tick fully processes its own batches: dispatch then drain (which loops only while the buffer saturates, dispatching everything it re-polls), then post. Nothing the inner tick leaves in ready_polls is un-dispatched, so discarding it is safe. The restore memcpys the outer batch and cursor back over that spent inner state, which is exactly what the outer dispatch needs to resume. Snapshot-on-entry / restore-on-exit brackets the whole inner tick, so depth nests correctly via the LIFO stack.

kqueue coalesced[]. Correct as you reasoned: coalesced[] is a stack local of each us_internal_dispatch_ready_polls frame, so the nested tick has its own and the outer's is untouched. The outer resumes its second pass reading coalesced[i] (its frame) paired with ready_polls[i] (restored to the same batch coalesced[] was computed from), so they stay consistent. A poll freed during the nested tick is nulled in the snapshot by us_internal_loop_update_pending_ready_polls; the second pass hits if (!poll) continue; before reading coalesced[i], so a stale flags entry is never used. On epoll the .events bits live in the epoll_event itself, which the snapshot memcpys, so the same consistency holds.

Struct layout. The PosixLoop layout checks are compile-time const _: () = { assert!(...) }, so any padding mismatch fails the build rather than corrupting at runtime. The trailing field is void* ready_poll_snapshots after int tick_depth (4 bytes + 4 pad + 8 ptr) on both sides, mirrored in InternalLoopData. bun run rust:check-all passes 10/10 targets.

On CI: build #62250 (current) is green on *-build-rust for every platform including darwin-x64 and linux-aarch64-musl; no checks are failing. Any earlier red was before the autofix re-trigger.

@robobun

robobun commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator Author

Status: diff is green, CI red is unrelated flake

The change itself is verified and passing:

  • Fail-before / pass-after confirmed on the debug (ASAN) build: the Bun.$ batch test times out on the unfixed build and passes with the fix.
  • bun run rust:check-all passes 10/10 targets; every *-build-cpp and *-build-rust lane is green on all platforms.
  • x64-asan leak lanes (streams-leak, fetch-leak, req-url-leak, bun-write-leak, etc.) report 0 fail, so the snapshot/restore and FilePoll invalidation introduce no leaks or UAF.

The two red runs are both external/infra flake, not this diff:

  • Build #62264: test/cli/install/migration/complex-workspace.test.ts fails at git clone https://bitbucket.org/dylan-conway/public-install-test.git returning HTTP 503 (external host down). It is a package-install test with no relation to the event loop.
  • Build #62250: :darwin: 14 aarch64 - test-bun was cancelled during VM boot (Terminated: 15, no tests ran). This test is Linux-only and was skipped there anyway; that build's Linux test lanes were green.

I have used my one CI re-roll (commit a5c3a114) and will not push further retriggers, since a re-run cannot fix an external 503. Ready for a maintainer to merge, or to re-run once bitbucket.org recovers.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find issues, but this changes core event-loop reentrancy semantics (snapshot/restore of ready-poll batches across nested ticks, plus cross-language struct layout and freed-poll invalidation), so it warrants a human look before merging.

Extended reasoning...

Overview

This PR modifies the core POSIX event-loop dispatch in bun-usockets to fix lost EPOLLONESHOT events when us_loop_run_bun_tick re-enters itself. It adds a heap-allocated LIFO snapshot stack of the outer ready_polls batch (in epoll_kqueue.c), a new ready_poll_snapshots field on us_internal_loop_data_t (mirrored in the Rust InternalLoopData repr(C) struct), extends us_internal_loop_update_pending_ready_polls to walk and rewrite all saved snapshots, exposes a new us_loop_invalidate_ready_poll C entry point with a Rust FFI wrapper, and reorders FilePoll::deinit_possibly_defer to call it before unregister. A Linux-only regression test exercises 34 concurrent Bun.$ commands with a forced nested tick.

Security risks

None apparent — this is internal event-loop bookkeeping with no auth, crypto, or untrusted-input handling. The risk surface is correctness/stability (UAF on stale poll re-dispatch, missed events, struct-layout mismatch across the C/Rust boundary) rather than security.

Level of scrutiny

High. This is the hot path every I/O operation in Bun flows through, and the change relies on subtle invariants: that current_ready_poll < num_ready_polls is true only mid-dispatch, that the inner tick leaves nothing un-dispatched before restore overwrites it, that kqueue's stack-local coalesced[] stays consistent with the restored ready_polls, that every poll-free path (uSockets sockets and Rust FilePolls) now nulls the entry in every snapshot to avoid re-dispatching freed memory, and that the new void* field's padding matches on all 10 Rust targets. The author has addressed several of these points in-thread with convincing reasoning, but the consequences of a mistake here are crashes or hangs across all of subprocess/pipe/socket I/O.

Other factors

The bug-hunting system found nothing, the PR is well-documented with a deterministic regression test, CI is reported green, and the author has already engaged with reviewer-style questions about restore ordering, kqueue coalescing, and struct layout. Still, the combination of reentrancy + manual memory management + cross-language ABI in the most critical loop in the runtime is exactly the kind of change a maintainer should sign off on rather than a bot.

@robobun robobun mentioned this pull request Jun 28, 2026

@alii alii left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root-cause work here is excellent, and the bug is real — I reproduced it on macOS as well (this PR's exact test body hangs 4/4 against an unfixed debug build on my machine, and passes without the nested-tick forcer), so it isn't Linux-specific. See the comment on the isLinux gate.

I don't want to take this shape of fix, though. It's a lot of new surface for the bug: a heap-allocated snapshot stack with a malloc/free + two ~12KB memcpys per nested tick, a new C API (us_loop_invalidate_ready_poll), a Rust FFI shim, a new InternalLoopData field, and a hook in FilePoll::deinit_possibly_defer. And the tell is why most of that exists: the whole invalidation half isn't fixing the original bug — it's defending the snapshot from what can happen during a nested tick (a FilePoll freed while its entry sits in the preserved copy). A fix that needs a second fix to protect itself is usually sitting at the wrong end of the invariant.

The alternative I'd like evaluated first: dispatch the outer remainder instead of preserving it

In the same current_ready_poll < num_ready_polls branch this PR adds at the top of us_loop_run_bun_tick, finish dispatching the outer batch's remaining entries (from current + 1) before the nested epoll_wait/kevent runs, instead of copying them aside. From reading the current code I think that's sound:

  • A completed dispatch's postcondition is current_ready_poll == num_ready_polls (epoll_kqueue.c:198, :275) — which is exactly the state a nested tick leaves behind, and why today's failure is a silent skip rather than a double dispatch. Drain the remainder first and that end state becomes correct. No snapshot, no restore, no LIFO.
  • Level-triggered sockets already get precisely this treatment today: the nested epoll_wait re-reports every still-ready LT fd from the outer remainder, and the nested dispatch runs their callbacks at the deeper nesting level while the outer callback is still on the stack. Only one-shot (EPOLLONESHOT / EV_DISPATCH) entries are trapped, because the kernel already disarmed them. So draining doesn't introduce a new reentrancy class — it extends to one-shot entries what LT entries already get.
  • With no preserved batch there is nothing to invalidate: us_loop_invalidate_ready_poll, its FFI declaration, the InternalLoopData field, and the deinit_possibly_defer hook all disappear — along with the (currently untested) use-after-free hazard they exist to prevent. Frees in the live batch stay covered by us_internal_loop_update_pending_ready_polls + the deferred hive free, exactly as before this PR.

Two honest caveats so nobody thinks it's free:

  • On kqueue, the dispatcher's coalescing pass merges duplicate kevents backward across the whole batch; a ..._from(start) variant must bound that merge window to [start, n), or a pending entry can coalesce into an already-dispatched slot and get lost.
  • It changes when the remainder runs (inside the nested tick, before the awaited promise settles). I couldn't find anything that depends on running at the outer depth — LT sockets already violate that today — but if there is such a consumer, that's a legitimate reason to reject the drain; it just needs to be written down.

If we want to kill the bug class, not just this instance

Stepping back: the reason this bug (and #30301's pidfd variant) exists at all is that a stack frame's iteration state — which batch is being dispatched and how far along it is — lives on the shared loop object (ready_polls / num_ready_polls / current_ready_poll), so any reentrant tick aliases it. The drain removes the harmful state at the reentry point; the structural end-state is for each dispatch to own its batch: read events into a frame-local buffer, iterate a frame-local cursor, and link live frames through an intrusive prev pointer on the loop so us_internal_loop_update_pending_ready_polls can scrub freed polls from every live frame's remainder (that one walk replaces both today's single-batch fixup and this PR's snapshot walk). Then a nested tick physically cannot clobber its parent — for this and any future reentrancy source — with no copies and no heap. That's a bigger refactor than either this PR or the drain, so I'm not asking for it here; but if we're adding machinery around this invariant, I'd rather it converge toward "the frame owns its batch" than toward "the shared batch gets copied aside and patched back". Either the drain now, or that refactor, would leave this file simpler than this PR does.

FWIW I went looking for problems in the snapshot mechanism itself — double dispatch of LT entries after the restore, the LIFO at depth ≥ 2, the cursor arithmetic, us_poll_resize/adopt against a live snapshot — and didn't find any. The mechanism is right; it's the amount of it, and the number of new invariants it hands to future readers, that I'm pushing back on.

So: either take the drain shape (happy to look at it quickly), or reject it explicitly in the PR description with the concrete reason. If the snapshot stays, the line comments below need addressing — the OOM fallback, the untested invalidation path, and the test's gate/trigger are each independently important.

Comment thread src/io/posix_event_loop.rs Resolved
@robobun

robobun commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Agreed on all of it. I'm switching this PR to the drain shape; thanks for the macOS repro and for writing the alternative up so precisely.

You're right about what the invalidation half is: it is not part of fixing the bug, it is defending the snapshot from a hazard the snapshot itself creates (a FilePoll freed during the nested tick, whose entry survives in the preserved copy because the nested autoTick runs process_deferred_frees before the outer dispatch resumes). With the drain there is no preserved copy to defend. The remainder is fully dispatched before the nested tick runs any user JS or process_deferred_frees, so a poll torn down during the drain is covered by exactly the mechanisms that cover the flat case today: us_internal_loop_update_pending_ready_polls over [current_ready_poll, num) plus IgnoreUpdates and the deferred hive free. So us_loop_invalidate_ready_poll, its header decl, the Rust FFI shim, the InternalLoopData field, and the deinit_possibly_defer hook all go, along with the untested UAF path your line comment called out.

I independently checked the two things the drain leans on and both hold:

  1. Termination is the existing loop postcondition. A completed us_internal_dispatch_ready_polls always leaves current_ready_poll == num_ready_polls (all three call sites, including us_loop_run and the saturation re-poll loop). Once the remainder is dispatched, the nested tick leaving the counters in that state makes the outer for exit correctly instead of skipping. That also handles depth >= 3 with no LIFO: a drained callback that re-enters sees current < num for its own frame's remainder, drains it, and each enclosing frame exits on the same postcondition when control unwinds.

  2. It does not introduce a new reentrancy class. As you said, every still ready level triggered fd in the remainder already gets re-reported by the nested epoll_wait and dispatched at the deeper level with the outer callback on the stack. The drain extends that to the one shot entries the kernel has already disarmed. A callback in the drained range that closes a socket or changes a poll is handled by the existing us_internal_loop_update_pending_ready_polls scan, whose [current, num) window is the drain's own cursor, and closed socket frees stay deferred to the outermost loop_post because tick_depth is already >= 2 when the drain runs. I went looking for anything that depends on the remainder running at the outer depth and found nothing; I'll record that in the code comment as you asked.

On the kqueue caveat: agreed, and I'll implement it as us_internal_dispatch_ready_polls_from(loop, start) with the coalescing pass iterating [start, n) and the backward merge bounded by j >= start, with the existing entry point becoming start = 0. That removes the loss case (a pending entry merging into an already dispatched slot). The one residual I want to name so it is a decision and not an oversight: an untagged socket whose kevents straddle start (one filter already dispatched with merged bits by the outer pass, the other in the drained range) gets its later filter dispatched again by the drain's fresh pass. If the earlier callback closed the socket, the later entry is already nulled; if it did not, it is one redundant callback on a live level triggered socket, which is within normal LT semantics. Tagged FilePoll entries never participate in coalescing, so they are unaffected. I'll put that in a comment next to the bound.

On the tests, taking all three:

  • skipIf(isWindows). You're right that I gated on where I reproduced rather than where the mechanism exists; OneShotFlag::Dispatch is EV_DISPATCH on kqueue, and the still one shot EVFILT_PROC exit watch on macOS makes the C layer fix more valuable there, not less. I'll fix the comment and say so in the description.
  • Making the trigger self checking. I'll expose the uws tick depth and the live batch's remaining count through bun:internal-for-testing and have the continuation assert, before it forces the nest, that it is running inside a poll dispatch with undispatched siblings. That is the precise precondition, so either refactor you named (expect().resolves no longer blocking, or finish() no longer draining inline) fails the test loudly instead of leaving it vacuously green. I'll also add a plain JS check that the nested tick actually ran (a Bun.sleep(0) continuation observed to have fired by the time the synchronous wait returns), which needs no internals.
  • A shell free variant. I'll attempt one (piped Bun.spawn children, nest from the first completion). The one honest constraint is that I will only keep it if it reliably fails on the unfixed build; the shell version is deterministic because finish() lands the continuation inside the dispatch of the batch that contains the siblings' pipe EOF events, and if I can't get a spawn only trigger to co batch that reliably I'd rather say so than ship a test the fail before gate can't trust.

Pushing the drain shortly.

…k overwrites it

Replaces the snapshot/restore approach with the shape suggested in review:
when us_loop_run_bun_tick detects it is nested inside a mid-iteration
dispatch (current_ready_poll < num_ready_polls, which a completed dispatch
never leaves true), it dispatches the outer batch's remaining entries before
its own epoll_wait/kevent can overwrite them.

A completed dispatch always leaves current_ready_poll == num_ready_polls, so
once the remainder is drained, the nested tick leaving the counters in that
state makes the outer for loop exit correctly instead of silently skipping.
That postcondition also handles arbitrary nesting depth with no extra state:
a drained callback that re-enters gets its own remainder drained the same
way, and each enclosing frame exits on the same check as control unwinds.

This does not introduce a new reentrancy class. Every still-ready
level-triggered fd in the remainder is already re-reported by the nested
epoll_wait and dispatched at the deeper level with the outer callback on the
stack; the drain extends the same treatment to the one-shot entries the
kernel has already disarmed and can never re-report. Callbacks that stop,
change, or free a sibling poll are covered by
us_internal_loop_update_pending_ready_polls exactly as in a flat dispatch.

Because nothing of the outer batch is preserved across the nested tick,
there is no saved copy for a FilePoll freed during the nested tick to
dangle in, so the previous commits' invalidation machinery
(us_loop_invalidate_ready_poll, its Rust FFI shim, the InternalLoopData
field, and the FilePoll::deinit_possibly_defer hook) is removed along with
the snapshot.

On kqueue the coalescing pass is bounded to [start, n) so a pending kevent
cannot merge into an already dispatched slot and get lost.

The regression test is self-checking: from inside the continuation it
asserts, via bun:internal-for-testing's event-loop stats (which now report
the uws tick depth and the live batch's undispatched remainder), that it is
running inline from a poll dispatch with undispatched siblings, and that a
nested tick really ran, so a refactor of either mechanism it relies on fails
the test instead of leaving it vacuously green. It runs on every POSIX
platform: the pipe readers are one-shot on kqueue too (EV_DISPATCH), and
macOS additionally still uses a one-shot EVFILT_PROC exit watch.
@robobun robobun changed the title usockets: preserve the outer ready-poll batch across nested event-loop ticks usockets: dispatch the outer ready-poll remainder before a nested tick overwrites it Jul 1, 2026
@robobun

robobun commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed the drain in a841c0d and updated the title and description to match.

Net diff vs main is now: epoll_kqueue.c (+78, mostly the comment you asked for recording the depth reasoning), the two getEventLoopStats fields that make the test self-checking, and the test. The snapshot, its invalidation API, the Rust FFI shim, the InternalLoopData field, and the deinit_possibly_defer hook are all gone. us_internal_dispatch_ready_polls gained a start parameter (existing callers pass 0), the kqueue merge window is bounded to [start, n) with the residual documented at the bound, and the drain itself is the one conditional at the top of us_loop_run_bun_tick.

Every line comment is answered and resolved in its thread. The one I want to surface here rather than bury: I attempted the shell-free Bun.spawn variant and am not shipping it, because I could not make it reliably fail on the unfixed build (details in the thread); I'd rather be honest about that than hand the fail-before gate a test it can't trust. The shell test now asserts its own preconditions through the exposed tick depth and pending count, so it no longer silently depends on the two implementation details you flagged.

Verified locally: the test passes 5/5 in ~0.4s on the drain build and hangs 8/8 on the unfixed release binary; pidfd-exit-nested-tick.test.ts plus the full bunshell.test.ts suite pass (377/0).

robobun and others added 2 commits July 1, 2026 20:11
…s-nested-tick-ready-polls

# Conflicts:
#	src/js/internal-for-testing.ts

@alii alii left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many comments. These comments don't need to be so long

@alii

alii commented Jul 1, 2026

Copy link
Copy Markdown
Member

@robobun ^

@alii

alii commented Jul 1, 2026

Copy link
Copy Markdown
Member

To make the review request concrete, here is the drain implementation, built and verified locally on macOS. @robobun please adopt this shape for this PR:

  • Replace the snapshot/restore in us_loop_run_bun_tick with the diff below (it applies to main).
  • Revert everything the snapshot needed: struct us_ready_poll_snapshot_t + the GET/SET_SNAPSHOT_POLL macros, us_loop_invalidate_ready_poll (+ its internal.h declaration), loop_data.h's ready_poll_snapshots, the src/uws_sys/Loop.rs + src/uws_sys/InternalLoopData.rs changes, and the deinit_possibly_defer hook in src/io/posix_event_loop.rs. None of it is needed once there is no preserved batch.
  • Take the test file below (it replaces the PR's): un-gated to macOS, asserts the trigger fired, plus a shell-free Bun.spawn/onExit variant.
  • Re-run the Linux verification from the PR description; I verified kqueue/macOS locally.

Fix

diff --git a/packages/bun-usockets/src/eventing/epoll_kqueue.c b/packages/bun-usockets/src/eventing/epoll_kqueue.c
index 7e347a378d..b3ab0be3da 100644
--- a/packages/bun-usockets/src/eventing/epoll_kqueue.c
+++ b/packages/bun-usockets/src/eventing/epoll_kqueue.c
@@ -52,6 +52,8 @@ void us_loop_run_bun_tick(struct us_loop_t *loop, const struct timespec* timeout
 #endif
 #endif
 
+static const struct timespec us_zero_timespec = {0, 0};
+
 /* Loop */
 void us_loop_free(struct us_loop_t *loop) {
     us_internal_loop_data_free(loop);
@@ -192,10 +194,12 @@ struct us_loop_t *us_create_loop(void *hint, void (*wakeup_cb)(struct us_loop_t
     return loop;
 }
 
-/* Shared dispatch loop for both us_loop_run and us_loop_run_bun_tick */
-static void us_internal_dispatch_ready_polls(struct us_loop_t *loop) {
+/* Shared dispatch loop for both us_loop_run and us_loop_run_bun_tick. A fresh
+ * batch passes first_index 0; a nested tick passes the first not-yet-dispatched
+ * index so it finishes the outer remainder before its own wait overwrites it. */
+static void us_internal_dispatch_ready_polls(struct us_loop_t *loop, int first_index) {
 #ifdef LIBUS_USE_EPOLL
-    for (loop->current_ready_poll = 0; loop->current_ready_poll < loop->num_ready_polls; loop->current_ready_poll++) {
+    for (loop->current_ready_poll = first_index; loop->current_ready_poll < loop->num_ready_polls; loop->current_ready_poll++) {
         struct us_poll_t *poll = GET_READY_POLL(loop, loop->current_ready_poll);
         if (LIKELY(poll)) {
             if (CLEAR_POINTER_TAG(poll) != poll) {
@@ -229,10 +233,14 @@ static void us_internal_dispatch_ready_polls(struct us_loop_t *loop) {
     };
 
     _Static_assert(sizeof(struct kevent_flags) == 1, "kevent_flags must be 1 byte");
-    struct kevent_flags coalesced[LIBUS_MAX_READY_POLLS]; /* no zeroing needed — every index is written in the first pass */
+    struct kevent_flags coalesced[LIBUS_MAX_READY_POLLS]; /* no zeroing needed — every index in [first_index, n) is written in the first pass */
 
-    /* First pass: decode kevents and coalesce same-poll entries */
-    for (int i = 0; i < loop->num_ready_polls; i++) {
+    /* First pass: decode kevents and coalesce same-poll entries. Bounded to
+     * [first_index, n): consumed entries are never consulted (they may hold
+     * freed polls). A pair straddling first_index dispatches once from each
+     * side; level-triggered sockets already tolerate that (spurious wakeups),
+     * and a poll closed by the first delivery has its later entries nulled. */
+    for (int i = first_index; i < loop->num_ready_polls; i++) {
         struct us_poll_t *poll = GET_READY_POLL(loop, i);
         if (!poll || CLEAR_POINTER_TAG(poll) != poll) {
             coalesced[i] = (struct kevent_flags){ .skip = 1 };
@@ -255,7 +263,7 @@ static void us_internal_dispatch_ready_polls(struct us_loop_t *loop) {
         /* Look backward for a prior entry with the same poll to coalesce into.
          * Kqueue returns at most 2 kevents per fd (READ + WRITE). */
         int merged = 0;
-        for (int j = i - 1; j >= 0; j--) {
+        for (int j = i - 1; j >= first_index; j--) {
             if (!coalesced[j].skip && GET_READY_POLL(loop, j) == poll) {
                 coalesced[j].readable |= bits.readable;
                 coalesced[j].writable |= bits.writable;
@@ -272,7 +280,7 @@ static void us_internal_dispatch_ready_polls(struct us_loop_t *loop) {
     }
 
     /* Second pass: dispatch everything in order — tagged pointers and coalesced events */
-    for (loop->current_ready_poll = 0; loop->current_ready_poll < loop->num_ready_polls; loop->current_ready_poll++) {
+    for (loop->current_ready_poll = first_index; loop->current_ready_poll < loop->num_ready_polls; loop->current_ready_poll++) {
         struct us_poll_t *poll = GET_READY_POLL(loop, loop->current_ready_poll);
         if (!poll) continue;
 
@@ -305,8 +313,7 @@ static void us_internal_drain_ready_polls(struct us_loop_t *loop) {
     int drain_count = 48;
     while (UNLIKELY(loop->num_ready_polls == LIBUS_MAX_READY_POLLS) && --drain_count != 0 && loop->num_polls > 0) {
 #ifdef LIBUS_USE_EPOLL
-        static const struct timespec zero = {0, 0};
-        loop->num_ready_polls = bun_epoll_pwait2(loop->fd, loop->ready_polls, LIBUS_MAX_READY_POLLS, &zero);
+        loop->num_ready_polls = bun_epoll_pwait2(loop->fd, loop->ready_polls, LIBUS_MAX_READY_POLLS, &us_zero_timespec);
 #else
         do {
             loop->num_ready_polls = kevent64(loop->fd, NULL, 0, loop->ready_polls, LIBUS_MAX_READY_POLLS, KEVENT_FLAG_IMMEDIATE, NULL);
@@ -316,7 +323,7 @@ static void us_internal_drain_ready_polls(struct us_loop_t *loop) {
             loop->num_ready_polls = 0;
             break;
         }
-        us_internal_dispatch_ready_polls(loop);
+        us_internal_dispatch_ready_polls(loop, 0);
     }
 }
 
@@ -338,7 +345,7 @@ void us_loop_run(struct us_loop_t *loop) {
         } while (IS_EINTR(loop->num_ready_polls));
 #endif
 
-        us_internal_dispatch_ready_polls(loop);
+        us_internal_dispatch_ready_polls(loop, 0);
         us_internal_drain_ready_polls(loop);
 
         /* Emit post callback */
@@ -355,6 +362,17 @@ void us_loop_run_bun_tick(struct us_loop_t *loop, const struct timespec* timeout
 
     loop->data.tick_depth++;
 
+    /* A poll callback re-entered the event loop mid-dispatch: the wait below
+     * overwrites ready_polls, dropping the outer batch's remaining events —
+     * unrecoverable for one-shot fds. Dispatch the remainder before that. */
+    if (loop->current_ready_poll < loop->num_ready_polls) {
+        us_internal_dispatch_ready_polls(loop, loop->current_ready_poll + 1);
+        /* The remainder's callbacks may have queued JS work that only our
+         * caller can run once this tick returns, and it chose `timeout` before
+         * they ran: poll for new events, never idle in the kernel. */
+        timeout = &us_zero_timespec;
+    }
+
     struct us_internal_callback_t *timer_callback = (struct us_internal_callback_t*)loop->data.sweep_timer;
 
     // Only integrate the loop if we haven't already.
@@ -406,7 +424,7 @@ void us_loop_run_bun_tick(struct us_loop_t *loop, const struct timespec* timeout
     } while (IS_EINTR(loop->num_ready_polls));
 #endif
 
-    us_internal_dispatch_ready_polls(loop);
+    us_internal_dispatch_ready_polls(loop, 0);
     us_internal_drain_ready_polls(loop);
 
     /* Emit post callback */

Why this is sufficient:

  • A completed dispatch leaves current_ready_poll == num_ready_polls, which is exactly the state a nested tick's own dispatch ends in — so after draining the remainder, the outer loop terminates cleanly when it resumes. No restore step, no snapshot stack, no heap allocation on the tick path.
  • Level-triggered entries in the outer remainder are already re-reported by the nested epoll_wait/kevent and dispatched inside the nested tick today. Draining extends that exact treatment to one-shot entries (the ones the kernel has already disarmed), so it introduces no new reentrancy class.
  • With no preserved batch there is nothing to invalidate on FilePoll teardown, so the entire cross-language invalidation half of the current diff (and the untested use-after-free hazard it guards) disappears. Frees in the live batch remain covered by us_internal_loop_update_pending_ready_polls + the deferred hive free, unchanged from main.

Two subtleties are deliberate — please keep them if you adopt this:

  1. Never idle after draining (the timeout = &us_zero_timespec line). The drained callbacks can queue JS work (resolve a promise) that only our caller can run once the tick returns — and the caller chose the wait timeout before that work existed. Without this, a nested tick whose awaited promise was settled by the drain can sleep on it. (The old code masked this by accident: still-armed level-triggered fds woke the wait immediately.)
  2. The kqueue coalescing pass is bounded to [first_index, n) and must never consult already-consumed entries. They can hold dangling pointers (a poll freed earlier in the batch whose address gets reused by us_poll_resize/adopt), so any "was this poll already delivered below first_index?" pointer comparison can produce a false match and silently drop a live event. The cost of not deduplicating across the boundary is only that a socket whose READ+WRITE kevents straddle the nesting point can be delivered once from each side — benign for level-triggered sockets (equivalent spurious re-deliveries already happen on every nested wait), and a poll closed by the first delivery has its remaining entries nulled by us_internal_loop_update_pending_ready_polls.

Test

// https://github.com/oven-sh/bun/pull/32233
// Subprocess pipe readers are one-shot (EPOLLONESHOT / EV_DISPATCH): if a poll
// callback re-enters the event loop while the outer ready-poll batch is still
// being dispatched, the batch's remaining (already-disarmed) events must not be
// dropped by the nested tick's wait, or their owners hang forever.
import { expect, test } from "bun:test";
import { isWindows } from "harness";

const N = 34;
const expected = Array.from({ length: N }, (_, i) => `out-${i}`);

// Windows readiness is driven by libuv, not this code path. Both macOS
// (kqueue, EV_DISPATCH) and Linux (epoll, EPOLLONESHOT) reproduce the hang.
test.skipIf(isWindows)("a batch of Bun.$ commands survives a nested tick from one command's continuation", async () => {
  let nested = false;

  const cmds = expected.map(out => {
    const cmd = Bun.$`printf %s ${out}`.quiet();
    // The first command to settle runs this continuation inline, during the
    // poll dispatch. Synchronously waiting on a promise (bun:test's .resolves
    // blocks via waitForPromise) forces a nested tick while the sibling
    // commands' one-shot pipe-EOF events are still in the outer batch.
    cmd.then(
      () => {
        if (!nested) {
          nested = true;
          expect(Bun.sleep(1)).resolves.toBe(undefined);
        }
      },
      () => {},
    );
    return cmd;
  });

  // Without the fix, the commands whose pipe-EOF event was dropped never
  // finish and this times out; nothing re-arms a disarmed one-shot pipe.
  const results = await Promise.all(cmds);

  expect(nested).toBe(true);
  expect(results.map(r => r.stdout.toString())).toEqual(expected);
});

// Same bug without the shell: the nested tick comes from a Bun.spawn onExit
// callback while sibling subprocesses' pipe-EOF events sit in the same batch.
test.skipIf(isWindows)("a batch of Bun.spawn pipe readers survives a nested tick from an onExit callback", async () => {
  let nested = false;

  const procs = expected.map(out =>
    Bun.spawn({
      cmd: ["printf", "%s", out],
      stdout: "pipe",
      stderr: "ignore",
      onExit() {
        if (!nested) {
          nested = true;
          expect(Bun.sleep(1)).resolves.toBe(undefined);
        }
      },
    }),
  );

  const outs = await Promise.all(procs.map(p => p.stdout.text()));
  await Promise.all(procs.map(p => p.exited));

  expect(nested).toBe(true);
  expect(outs).toEqual(expected);
});

Verification (macOS, kqueue, Apple Silicon, debug build)

unfixed (main) with this patch
Bun.$ nested-tick test hangs, times out (4/4) passes (6/6)
Bun.spawn onExit nested-tick test wedges the runner outright (4/4) passes (6/6)
USE_SYSTEM_BUN=1 bun test (release 1.3.14) both tests fail (5s timeouts) —
test/js/bun/shell/ + test/js/bun/spawn/ suites baseline no new failures vs the same run on main

The spawn variant is worth keeping: on an unfixed build it wedges the whole runner (not even the per-test timeout fires), i.e. the lost-event class is not limited to shell pipe EOFs.

Takes the implementation and test from review verbatim. Beyond shortening
the comments and dropping the _from wrapper, it fixes a liveness bug in the
previous revision: after dispatching the outer remainder, the nested tick
must not idle on the timeout its caller computed before the drained
callbacks ran, since one of them may have settled the very promise the
caller is waiting on. Poll with a zero timeout instead.

Also reverts the getEventLoopStats additions (tickDepth, pendingReadyPolls):
the replacement test does not use them.
@robobun

robobun commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Adopted verbatim in eca4e42, thanks. The timeout = &us_zero_timespec line is a real liveness bug you caught in my version, not just shape: I had the nested tick idling on a timeout chosen before the drained callbacks ran.

Also in that commit: your test file replaces mine, the getEventLoopStats additions are reverted (nothing uses them now), and the long code comments are gone. Net diff vs main is epoll_kqueue.c plus the test.

Linux verification: Bun.$ test times out 3/3 on the unfixed release binary and passes 5/5 fixed; pidfd-exit-nested-tick plus the full bunshell suite pass (377/0). One data point for you: the Bun.spawn/onExit variant does not reproduce on unfixed Linux/epoll (3/3 pass), so it is the kqueue fail-before you measured rather than a cross-platform one. Kept as is since it costs nothing on Linux and is the stronger case on macOS.

@robobun
robobun requested a review from alii July 1, 2026 20:55
@robobun

robobun commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Status: do not merge yet. CI caught a real regression in the drain (both my version and the adopted one), and I want to be the one to say it clearly.

test/bake/dev/production.test.ts > "works with sourcemaps - error thrown in React component" times out at 90s (270s on ASAN), 4 out of 4 retries, on every POSIX lane, on both of this branch's builds (67663, 67679). It is the 3rd file the lane runs, the file's other bake tests pass immediately before and after it, and main at this branch's exact merge base (build 67643) plus the three prior full green main builds show no history of it even flaking. So it is not load, not flake, and not inherited from main.

The failing test is await Bun.$\bun build --app ...`.throws(false): a shell command whose child prints a large stderr error dump and exits 1. The captured output shows the child produced all of its output, and the runner reports no dangling child at the timeout, which points at the parent's Bun.$` promise never settling after the child finished. That is the same shape as the bug this PR fixes, so the drain is evidently introducing the event loss (or a shell state wedge) in a configuration my 34-printf regression test does not cover: one command, heavy stderr, nonzero exit.

I could not reproduce it on my box and I now distrust every local timing I collected: this container shares a host that is sitting at load 60-100, and with events trickling in one per batch there is never a mid-iteration remainder, so (per temporary instrumentation) the drain never even executes locally. On CI, where the child's stdout EOF, stderr EOF, and exit land in one batch, it does. I am instrumenting from here to get the mechanism rather than guessing; the one honest hypothesis I have is that dispatching the remainder inside the interrupted callback's own stack frame can deliver a sibling event of the same logical object (the same command's other pipe, its exit) reentrantly into a state machine that is mid-transition below it, which is a stronger reentrancy than the level-triggered precedent we both leaned on (those are re-delivered by the nested wait, from a fresh batch, and evidently in an order this test depends on).

I will follow up with either the mechanism and a corrected fix, or a revert of the drain commit plus what I learned. Sorry for the churn; your review direction (no snapshot, no invalidation machinery) still stands, the remaining question is only how the preserved remainder gets delivered.

@robobun

robobun commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Correction, and I want to be precise because my previous comment told you the drain regressed CI: it did not. I withdraw that, with apologies; here is the evidence that overturned it.

  • There was never a green-main baseline. Merge builds on main do not run the test lanes at all (build 67643, my merge base, has zero test jobs), so "main is green on this test" was a measurement of nothing.
  • The bake failure is fleet-wide. The six most recent failed builds from six unrelated branches (67646, 67647, 67659, 67662, 67664, 67665) all fail the same works with sourcemaps test the same way, and most also show the test-net-connect-memleak error my build shows. This branch's two red builds match the fleet's current failure set exactly. Filed as bake: "works with sourcemaps - error thrown in React component" times out on every CI build #33214.
  • Locally the stock release bun (no drain) hangs the same bun build --app child on a clean fixture identically to my build, and instrumentation shows the drain never executes in that workload at all, in either the parent or the child. The child spins in JS after printing the SSG errors; it is a bake bug, not an event-loop one.

So the facts stand as they were before my false alarm: this PR's own tests pass on every lane, nothing red in either build is attributable to the diff, and the drain has no counter-evidence against it. The only thing my wrong conclusion was built on was an invalid baseline plus an oversubscribed local box, and I should have checked other branches' builds before pointing at the code. The do-not-merge is withdrawn; CI will stay red on the unrelated bake test until #33214 is fixed, so that is the only thing between this and a clean board.

@cnrad

cnrad commented Jul 2, 2026

Copy link
Copy Markdown

@robobun Hi

@robobun

robobun commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @cnrad!

Quick status in case that is what you are after: the fix here is the shape alii proposed (dispatch the outer ready-poll remainder before a nested tick overwrites it), adopted verbatim in eca4e42 along with their test. This PR's own tests pass on every lane. The remaining CI red is bake/dev/production.test.ts, which is currently timing out on every PR on Buildkite (six unrelated branches show the identical failure) and is unrelated to this change; it is tracked in #33214. So the PR is waiting on a re-review from alii, and on #33214 for a clean board. Happy to answer anything specific.

@alii

alii commented Jul 2, 2026

Copy link
Copy Markdown
Member

@robobun — one more datapoint would make the coverage story airtight, and only your Linux box can produce it cheaply.

The regression test forces the nested tick explicitly (the .then does expect(Bun.sleep(1)).resolves, which blocks via waitForPromise). That's the deterministic trigger, but the field reports this PR is based on were plain concurrent Bun.$ in long-running processes — no test matchers anywhere. The PR description says the raw shape (Promise.all(34 × Bun.$…quiet()), no forcer) hangs on an unfixed Linux release build; I could not reproduce the raw shape on macOS (0/8 — there, some synchronous wait in a continuation is needed), so I'd like the Linux claim pinned down properly:

  1. Run the no-forcer snippet from the PR description as a plain script (bun script.js, fresh process each time — cold start matters, the hang lives in the first crowded batch) ~20× on your unfixed build, and ~20× on the fixed build. Report hang counts for both.
  2. If an unfixed run hangs: grab gdb -p <pid> -ex 'thread apply all bt' -batch of the wedged process and paste the JS-thread stack. If this bug is what's biting, the stack reads us_internal_dispatch_ready_polls → … → waitForPromise/tickWhilePaused → us_loop_run_bun_tick → epoll_wait — a wait for the loop nested inside a dispatch of the loop. That single stack would (a) prove plain concurrent Bun.$ re-enters the tick with no help from test code, and (b) name which runtime path does the re-entering in a bare script, which is the one thing this PR's writeup still infers rather than shows.

If the raw shape genuinely doesn't reproduce on your box either, that's important too — say so, and we'll know the one-shot loss needs some synchronous-wait source in the process (module loader, macros, HTMLRewriter, bake, test matchers, …), which is worth a sentence in the PR description for whoever reads it in two years.

@robobun

robobun commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Done. Numbers first; 20 cold bun x.mjs processes per cell, scripts inlined below.

script unfixed (release, d816daf4, no drain) fixed (debug, eca4e42)
raw.mjs: await Promise.all(34 x Bun.$\printf %s out-i`.quiet())`, nothing else 0/20 hang 0/20 hang
withrewriter.mjs: same, plus the first command's continuation calls a plain runtime API that waits synchronously 20/20 hang 0/20 hang
// withrewriter.mjs: the only difference from raw.mjs
cmds[0].then(() => {
  new HTMLRewriter().on("p", { async element(el) { await Bun.sleep(30); } }).transform("<p>x</p>");
});

So you are right, and thank you for pressing on it: the raw shape does not reproduce on Linux either (consistent with your 0/8 on macOS), and the PR description overstated it. I am correcting the description. A bare .then chain never re-enters the loop; the loss needs the interrupted callback, or a continuation it drains inline, to wait synchronously on something event-loop driven. Two non-triggers worth recording since I tested them: require() of an ordinary module resolves inside the task drain and never reaches a nested epoll_wait, and require() of a module with top-level await is refused outright (ERR_REQUIRE_ASYNC_MODULE), so lazy requires in callbacks are not a source. The in-tree synchronous-wait sources reachable from user code are the waitForPromise callers: bun:test's async matchers, HTMLRewriter.transform with an async handler, Bun.build plugin callbacks that return promises, macros, the module and entry loaders, bake's render paths, and the REPL. Any one of those in a continuation of a busy batch is the production shape, and a long-running app on heavy commands has plenty of candidates.

The stack you asked for, captured on the unfixed binary during the nested window (gdb on bun-profile; variant where the handler awaits 8s so the window is wide):

#0  sys_epoll_pwait2                        src/platform/linux.rs:102
#1  bun_epoll_pwait2                        packages/bun-usockets/src/eventing/epoll_kqueue.c:142
#2  us_loop_run_bun_tick                    packages/bun-usockets/src/eventing/epoll_kqueue.c:394
#3  auto_tick                               src/uws_sys/Loop.rs:253
#4  auto_tick                               src/jsc/VirtualMachine.rs:2242
#5  auto_tick                               src/jsc/event_loop.rs:908
#6  wait_for_promise                        src/jsc/event_loop.rs:934
#7  wait_for_promise                        src/jsc/VirtualMachine.rs:2233
#8  handler_callback<ElementHandler, ...>   src/runtime/api/html_rewriter.rs:1310
#9  on_element                              src/runtime/api/html_rewriter.rs:1379
    ... lol-html parser frames ...
#33 Body::run                               src/runtime/webcore/Body.rs:2357
#34 HTMLRewriter init / begin_transform     src/runtime/api/html_rewriter.rs:751, 401
    (gdb cannot unwind past the JS frame that called transform)

gdb cannot name the native frames below the JS boundary, so instead of showing us_internal_dispatch_ready_polls I printed the loop state from frame 2 at that instant: loop->data.tick_depth == 2. tick_depth only increments inside us_loop_run_bun_tick, so a value of 2 here means a second us_loop_run_bun_tick is live beneath the JS, which is only possible if the JS was invoked from inside the outer tick's poll dispatch; a continuation drained outside a dispatch would nest at depth 1. Together with frames 0 through 7 that is the sandwich you predicted, with the bare-script re-entry path named: the first command finishes inside the dispatch, finish() drains microtasks inline, the user continuation calls a synchronously waiting API, waitForPromise runs autoTick.

No code changes from any of this; withrewriter.mjs going from 20/20 hangs to 0/20 under the fix is extra validation of the drain through a trigger that is not bun:test.

@alii

alii commented Jul 2, 2026

Copy link
Copy Markdown
Member

Thanks — that's exactly the datapoint set I wanted, and the tick_depth == 2 readout is the smoking gun. Three small things to fold in while you're correcting the description, then I'm done asking:

  1. Description language. State the trigger requirement precisely: the loss needs the interrupted callback (or a continuation it drains inline) to synchronously wait on the event loop — i.e. one of the waitForPromise callers (bun:test async matchers, HTMLRewriter.transform with an async handler, Bun.build plugin callbacks, macros, the module/entry loaders, bake's render paths, the REPL). A bare .then chain never re-enters the loop, and plain concurrent Bun.$ does not hang by itself (your 0/20, my 0/8).

  2. Test hardening. Please fold your withrewriter.mjs shape into test/js/bun/spawn/pipe-reader-nested-tick.test.ts as a third case. Both current tests force the nested tick via expect(Bun.sleep(1)).resolves, which only works because bun:test's matcher happens to block synchronously — an implementation detail, and the tests' weakest link (I flagged it in review). HTMLRewriter.transform with an async handler is contractually synchronous, so a case built on it can't be silently defused by a future bun:test refactor. You've already written it; it's ~10 lines.

  3. Please don't add the suggested Fixes #26580 / #27766 / #32178 block without re-triaging each one against the now-precise trigger requirement. All three read as raw shapes (big-output shell loops, many concurrent spawns) with no synchronous-wait API anywhere in the report — and we just established the raw shape doesn't lose events. If those hangs are a different bug, auto-closing them on merge buries real reports. Better: leave them open and re-test each against a build of this branch.

The two existing cases force the nested tick through expect().resolves,
which blocks synchronously only as an implementation detail of bun:test's
matcher. HTMLRewriter.transform with an async element handler must wait for
the handler's promise before returning, so this case cannot be defused by a
future matcher refactor. Same batch geometry, no test-runner machinery in
the trigger.

Times out on an unfixed build and passes with the fix, like the others.
@robobun

robobun commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

All three folded in, pushed as 7e1e702.

  1. Description: the Repro section now states it in your terms. Concurrency alone is not sufficient and a bare .then chain never re-enters the loop; the loss needs the interrupted callback, or a continuation it drains inline, to synchronously wait on the event loop via one of the waitForPromise callers (bun:test async matchers, HTMLRewriter.transform with an async handler, Bun.build plugin callbacks, macros, the module and entry loaders, bake's render paths, the REPL), with the 0/20 and 0/8 raw-shape numbers right there.

  2. Test: added the HTMLRewriter case to pipe-reader-nested-tick.test.ts as a third variant with the same batch geometry, with a comment saying exactly why it exists (contractually synchronous wait, so a future bun:test matcher refactor cannot defuse the file). Verified both ways: it times out on the unfixed system build and all three cases pass on the fixed build in ~0.3s each.

  3. Agreed, and no action needed: I never added a Fixes block for Bun Shell hangs with git show command, spawnSync from node:child_process succeeds #26580 / Event loop busy-spins at 100% CPU when spawning concurrent bun processes using Ink + fetch (macOS ARM64) #27766 / Regression in 1.3.14: deterministic segfault in MicrotaskQueue drain after subprocess ready-poll (works on 1.3.13, still crashes on 1.4.0 canary) #32178 and will not. When the find-issues bot suggested them I posted a triage comment declining to auto-close for the same reason you give (I could not reproduce any of them, and Event loop busy-spins at 100% CPU when spawning concurrent bun processes using Ink + fetch (macOS ARM64) #27766 is a busy-spin, which is not this bug's shape). With the trigger requirement now precise, I agree all three read as raw shapes and should stay open until someone re-tests them against this branch.

@robobun

robobun commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the review and for the better fix shape. For whoever merges: the only red on CI is test/bake/dev/production.test.ts, which is currently failing on every PR (tracked in #33214) and is unrelated to this change; every test in this PR passes on all lanes.

@alii

alii commented Jul 2, 2026

Copy link
Copy Markdown
Member

I'm closing this, and I owe the PR a precise explanation, because the code here is not wrong — I approved it earlier today — and the investigation behind it is some of the best diagnostic work this bug class has gotten. This is a direction decision, not a correctness one.

The decision. A nested us_loop_run_bun_tick starting while us_internal_dispatch_ready_polls is mid-batch should not be a situation the dispatcher learns to survive; it is a bug in whoever re-entered. The only legitimate uses of waitForPromise ("run the event loop until this promise settles") are the ones whose synchronous outer context is inherent — the module pipeline and top-level drivers: entry-point module-graph evaluation (ES module evaluation is async by spec, even for fully synchronous code), macro loading/evaluation inside the transpiler, and the REPL / CLI drivers. All of those run at top level, where no dispatch is in flight, so they cannot corrupt a batch. Every other caller is API sugar — a synchronous signature over an asynchronous operation — reachable from inside I/O completion callbacks, and that is exactly where this bug class is born.

Teaching the dispatch loop to tolerate mid-batch re-entry (which is what the drain does — correctly!) locks in the wrong invariant. Once it lands, the next blocking API someone adds is silently fine instead of loudly wrong, and the reentrancy never goes away. I would rather fix the callers and forbid the state.

What we'll do instead (tracking issue to follow):

  1. expect(p).resolves / .rejects / async toThrow stop blocking the event loop and return real promises (Jest semantics). bun:test will settle floating matcher promises at test end so existing un-awaited usage does not become silently vacuous.
  2. HTMLRewriter.transform() with async handlers returns a promise (the synchronous form with async handlers is deprecated).
  3. Audit and de-block the remaining in-tree waitForPromise callers that can run inside I/O callbacks (bake's render paths, Bun.build plugin waits).
  4. Add a debug-build assertion at tick entry on exactly the condition this PR identified — loop->current_ready_poll < loop->num_ready_polls at us_loop_run_bun_tick entry means "someone synchronously waited on the event loop from inside a dispatch callback" — so any future violation fails CI loudly instead of shipping as a rare hang. No-op in release builds.
  5. Re-home this PR's three regression tests: after (1) and (2) they become the tests that those APIs no longer re-enter the loop, and that the debug assertion catches whoever does.

What this PR established, which all of the above stands on: the loss mechanism (one-shot fds + a clobbered ready_polls batch), the exact trigger requirement (plain concurrent Bun.$ never hangs by itself — 0/20 on Linux, 0/8 on macOS; the loss needs a waitForPromise caller in a continuation), the complete caller inventory, a gdb-verified nested-tick stack with tick_depth == 2, and three deterministic repros. Thank you — genuinely — for the speed and the rigor, and for taking two rounds of review pushback and making the patch better each time. I'm sorry to close good work; I'd rather pay that than commit the event loop to a reentrancy contract we don't want.

The honest cost of closing: until (1) and (2) ship, the expect().resolves + concurrent-subprocess hang remains reproducible on current releases (this PR's own test file is the repro). That window is accepted deliberately. Workaround in the meantime: await your expect().resolves / .rejects chains (what Jest semantics ask of you anyway), and don't call HTMLRewriter.transform with async handlers from inside I/O callbacks.

@alii

alii commented Jul 2, 2026

Copy link
Copy Markdown
Member

Tracking issue for the direction above (de-block the blocking callers, then assert that nothing re-enters the loop mid-dispatch): #33261

@robobun

robobun commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

That is the right call, and thank you for writing it down so precisely. "The dispatcher should not learn to survive a state that is itself a bug" is a better invariant than the one this patch would have locked in, and the debug assertion in #33261 is the part I wish I had proposed: it turns every future blocking API added inside an I/O callback into a loud CI failure instead of a one-in-a-thousand hang.

Everything transferable is already here for whoever picks up #33261: the waitForPromise caller inventory, the exact assertion condition (current_ready_poll < num_ready_polls at us_loop_run_bun_tick entry), the three regression tests in test/js/bun/spawn/pipe-reader-nested-tick.test.ts (which re-home as the non-blocking matcher test, the HTMLRewriter-returns-a-promise test, and the assertion's positive case), and the two standalone 20-run scripts in the comments above if a bare-script repro is useful. If help is wanted on any of the five items, I am happy to take them.

Thanks for the three rounds of review. The patch got better each time, and the thing that replaced it is better still.

Jarred-Sumner pushed a commit that referenced this pull request Oct 21, 2026
…run (#46335)

### Problem
- A callback of a TLS socket over a stream turns the event loop
synchronously while the socket closes. Debug builds report
`AddressSanitizer: heap-use-after-free` in `us_ssl_wrapper_keylog` under
`SSL_do_handshake`, or in `SSLWrapper::flush_pending_events`. Release
builds end with `panic: RefCell already borrowed` or stay silent.
- `DuplexUpgradeContext::on_close` (`src/runtime/socket/socket_body.rs`)
queued the task that frees the context at once. The nested turn ran it
under the TLS engine.
- Found by audit. No issue or crash report names it.

### Fix
- `DuplexUpgradeContext` is refcounted. The open connection holds one
ref, and each `UpgradedDuplex` entry point holds one while it runs. The
free task is queued at zero.
- No free task exists while an entry point runs. A debug assertion
checks that handlers run under a ref.
- Verified: `test/js/node/tls/node-tls-duplex-close-throw-uaf.test.ts`.
Ten cases abort on the base build and pass with the fix. Also twelve
TLS, http2 and module-graph suites (Notes).
- Self-reviewed: 12 concerns raised, 11 addressed. One exit has no test
(Notes).

### Background
- `DuplexUpgradeContext` owns `UpgradedDuplex`, which owns the TLS
engine (`SSLWrapper`) behind `tls.connect({socket})`.
- `expect(promise).resolves` and `Bun.build` with an async plugin
`setup()` run queued tasks while they wait.
- Considered a check in the free task. It parks the free and polls.
`WindowsNamedPipe` (#39983) holds a ref at its entry points.

### Downsides
- Duplex TLS pays 9 instructions per guarded entry. An echo measures
+0.11% instructions, and a control with no guard +0.06%.
- A transport error before the engine starts takes 2 queue entries, not
1.
- The binary grows by 8,192 bytes and one test-only host function.

<details><summary>Notes</summary>

#### What turns the loop, and what closes the socket

- The wait is `EventLoop::wait_for_promise` (`src/jsc/event_loop.rs`).
It calls `tick()`, which runs the task queue. The fixture uses two
callers: a `bun:test` promise matcher in a plain script, and `Bun.build`
with an async plugin `setup()` (`src/runtime/api/JSBundler.rs`).
- The callback does not have to close the socket. Three of the ten cases
close it from elsewhere: a `destroy()` in a later turn (the callback is
the transport's `final()`), a transport that closes during the turn, and
a `Bun.ModuleGraph` that is disposed.
- #44618 covered an ALPNCallback that destroys its socket with no loop
turn (it kept the `SSL` until the pass ends). The owner was still freed
by the queued task.

#### The ten cases on the base build (debug, ASAN)

Each one ends in `heap-use-after-free`. The free is
`DuplexUpgradeContext::deinit` from `run_event`, or from `release_unrun`
for the disposed graph.

| Case | Top frames of the read |
|---|---|
| ALPNCallback | `us_ssl_wrapper_keylog` < `us_ssl_keylog_cb` <
`SSL_do_handshake` |
| server 'keylog' | `SSLWrapper::flush_pending_events` < `traffic_pass`
|
| client 'secureConnect' | `UpgradedDuplex::is_shutdown` <
`UpgradedDuplex::on_handshake` |
| server 'data' | `SSLWrapper::dispatch_read` < `handle_reading` |
| server 'data', turned by `Bun.build()` | `SSLWrapper::dispatch_read` <
`handle_reading` |
| client 'data' | `SSLWrapper::dispatch_read` < `handle_reading` |
| the transport's `write()` | `SSLWrapper::handle_writing` <
`write_data` |
| the transport's `final()`, `destroy()` in a later turn |
`UpgradedDuplex::finish_close` < `on_close` |
| server 'data', the transport closes during the turn |
`SSLWrapper::dispatch_read` < `handle_reading` |
| server 'data', its `Bun.ModuleGraph` is disposed |
`SSLWrapper::dispatch_read` < `handle_reading` |

Release build of the base, original repro (ALPNCallback destroys the
socket, then `expect().resolves`): `panic: RefCell already borrowed`, 5
of 5 runs. The 'keylog' variant printed OK 5 of 5 (silent). Sentry was
not queried.

#### How the tests decide

- The fixture counts live contexts through
`duplexTLSInternals.liveCount()`, so the tests do not need ASAN to fail.
- Each callback case has a third context that nothing holds. The turn
frees it. That shows that the turn ran the queued tasks: the report is
`{ before: 3, afterTurn: 2, afterClose: 0 }`. With no turn it is 3, and
with the fault it is 1.
- The turn is a promise that a microtask settles, so one `tick()` runs.
One case turns with `Bun.build()` instead, so the test does not depend
on the matcher alone.
- The fourth test ends a connection in seven ways and expects zero
contexts left. It does not abort on the base build. There it fails
because the counter does not exist.
- Each guard clause was removed once on the debug build (by a jump in
gdb) to confirm that a test notices:
- no `teardown()` in `release_unrun`: a string from the transport
reaches the disposed graph as `ERR_STREAM_WRAP`.
- no `abort_handle.leave()`: `DuplexUpgradeContext entered after its
last ref was released`.
- the count check in `release_unrun`: the graph case reaches it with a
count of 1, so an unconditional free trips the assertion in `deinit`.

#### Direction

- #33261 asks that nothing re-enters the event loop from a dispatch
callback. #32233 was closed for that reason: it made the dispatcher
tolerate re-entry. #33289 moves the `bun:test` matchers off the nested
wait.
- This change does not touch the dispatcher or the loop. It fixes a
memory fault at one owner, in the shape of `REVIEW.md` ("bracket entry
points that can reach synchronous teardown with ref()/defer deref()")
and of #39983.
- The trigger stays reachable after #33289: `Bun.build` still waits for
an async `setup()` (#33271 was closed without a merge).

#### Sequencing

- This lands first. Two open PRs add entry points to `UpgradedDuplex`
and need the guard after it:
- #45471: `UpgradedDuplex::resolve_server_name` (an SNICallback that
answers in a later turn) needs the `keep_alive()` guard as its first
statement, and `DuplexUpgradeContext::on_server_name` needs the
`debug_assert_kept_alive()` call. Without them the debug build aborts on
the assertion.
  - #43877: the `on_write_done` thunk needs the guard.
- #40139 rewrites the same lines and keeps the unconditional free in the
`Close` arm. A rebase must keep the rule: the `Close` hop is queued only
at zero.

#### Not in this change

- `WindowsNamedPipe`: #39983 guards `on_read`, `on_read_error`,
`on_error`, `on_handshake` and `get_accepted_by`. Seven entries that
dispatch have no guard: `on_writable`, `flush`, `on_timeout`,
`encode_and_write`, `raw_write`, `close`, `shutdown`. No fault is known
there: its transport is libuv and runs no script in write, end, pause or
resume. Read from the code, not run on Windows. Do not copy `keep_alive`
to those entries as is: there, a ref taken at zero queues the free
twice.
- `ProxyTunnel` (`src/http/ProxyTunnel.rs`) runs on the HTTP thread,
where no script runs.
- The start-failure exit of the `StartTLS` arm now releases the
connection's ref. It has no test. `node:tls` and `node:http2` pass a
prebuilt `SSL_CTX`, so the start fails only if `SSL_new` fails.

#### Measurements (linux x64, base 71bc818)

- Instructions: `perf` is not installed here. The counts are
`perf_event_open` (`PERF_COUNT_HW_INSTRUCTIONS`, user only) around the
release binaries. One TLS echo over an in-process Duplex pair, 100,000
round trips of 1 KiB, `BUN_JSC_useJIT=0`, 10 interleaved runs each.
- base 32,160,640,513, this PR 32,197,252,048: +366 per round trip of
321,600 (+0.11%). Run-to-run spread: 0.09% to 0.13%.
- The same echo over loopback TCP (no guard on the path): base
20,199,900,220, this PR 20,211,412,604 (+0.06%). Spread: 0.07% to 0.11%.
- Disassembly of `UpgradedDuplex__flush`: 4 instructions at entry and 5
at exit. A round trip takes 4 guards (gdb count on the debug build).
- `sizeof(DuplexUpgradeContext)`: 568 B -> 568 B (gdb on the debug
builds). The two fields fit in padding.
- Queue entries per duplex TLS socket (gdb hit counts on `run_event`, 50
cycles): normal close 2 -> 2, `destroy()` before the engine starts 2 ->
2, transport error before the engine starts 1 -> 2.
- Live contexts: 2 of 3 inside the callback after the turn, 0 after
unwinding. 0 after 1,000 cycles of each of three orders on the release
build (4,000 sockets).
- Release binary (`llvm-size`): `.text` 81,904,741 -> 81,909,861
(+5,120), `.rodata` +4,096, file 107,497,184 -> 107,505,376 (+8,192).
Host functions: +1, testing only.

#### Suites (debug build, `--timeout 90000`)

Same results as the base build: `node-tls-duplex-end-verify` (115),
`node-tls-duplex-write-throw-error-value` (1),
`node-tls-wrapped-socket-close` (113), `node-tls-server` (218),
`node-tls-upgrade` (21), `node-http2-upgrade` (23), `renegotiation`
(58), `node-tls-context` (83), `tls-fatal-error-closes` (38),
`tls-reject-before-client-cert` (126), `module-graph-io` (28),
`module-graph-isolation` (413). `node-tls-connect` has the same 4
failures on both builds: those tests contact bun.sh, which this machine
cannot reach. `cargo clippy -p bun_runtime` and
`test/internal/source-lints/` are clean.

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants