Skip to content

bun test: drain the event loop for script files with no test() registrations - #34862

Open
robobun wants to merge 15 commits into
mainfrom
claude/farm/14b6b439/test-drain-script-files
Open

bun test: drain the event loop for script files with no test() registrations#34862
robobun wants to merge 15 commits into
mainfrom
claude/farm/14b6b439/test-drain-script-files

Scope the script-file drain to handles created by that file

80cdf80
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 21, 2026 in 24m 54s

Code review found 2 important issues

Found 5 candidates, confirmed 3. See review comments for details.

Details

Severity Count
🔴 Important 2
🟡 Nit 1
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important src/runtime/cli/test_command.rs:3244-3252 Scalar-count baseline cannot attribute post-snapshot handle changes — hang and false-pass
🔴 Important src/runtime/cli/test_command.rs:3145-3149 Preload handles are not in the baseline for the first file — hang regression

Annotations

Check failure on line 3252 in src/runtime/cli/test_command.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

Scalar-count baseline cannot attribute post-snapshot handle changes — hang and false-pass

The scalar `count > baseline` comparison only excludes handles that exist *at* snapshot time, not ones whose state changes after it: a prior file/`--preload` callback that fires during this drain and net-creates ref'd handles (delayed `Bun.serve`, connection-pool open, retry fan-out) pushes count above baseline permanently and the loop **hangs** with no timeout — a regression from the pre-PR exit 0. Conversely, a prior file's *transient* handle completing inside the drain drops count to baseline

Check failure on line 3149 in src/runtime/cli/test_command.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

Preload handles are not in the baseline for the first file — hang regression

The baseline is snapshotted *before* `load_entry_point_for_test_runner`, but `--preload` scripts execute *inside* that call (via `reload_entry_point_for_test_runner` → `(hooks.load_preloads)(self)` at VirtualMachine.rs:4624) — so on the first test file, a preload's `setInterval`/`Bun.serve` counts *above* baseline and a script-style file hangs forever in the drain loop. The comment at 3242-3243 and the fix response both claim preload handles are "excluded by the baseline", but that's only true f