test: give worker-shutdown-post-leak an explicit 90s timeout - #38157
test: give worker-shutdown-post-leak an explicit 90s timeout#38157robobun wants to merge 1 commit into
Conversation
The test is ASAN-only. Under a debug+ASAN build on a loaded machine the worker boot and VM teardown it spawns take 5-7s, so it times out at the 5s default, and when LSan does find a leak, symbolizing the report against the debug binary needs several seconds more, so a real regression also surfaced as a timeout with the report cut off. Same budget as the other LSan guard tests (shell-worker-terminate-leak, spawn-stdin-pipe-fd-leak).
|
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 (1)
Comment |
|
Updated 5:05 AM PT - Aug 13th, 2026
❌ @robobun, your commit 4d0e56f has some failures in 🧪 To try this PR locally: bunx bun-pr 38157That installs a local version of the PR into your bun-38157 --bun |
|
Status: ready for review.
|
There was a problem hiding this comment.
LGTM — test-only timeout bump matching the established 90s budget used by the other LSan guard tests.
What was reviewed:
- Confirmed
shell-worker-terminate-leak.test.tsandspawn-stdin-pipe-fd-leak.test.tsboth already use90_000for the same reason, so this follows the existing pattern rather than inventing one. - Checked against the "don't raise timeouts to make a slow test pass" rule — the workload is already minimal (one worker, two writes); the cost is debug+ASAN worker boot and LSan symbolization, which the test cannot shrink.
- The added comment is concise and explains both the pass-path and fail-path timing, which the code alone cannot convey.
Extended reasoning...
Overview
Single-file, test-only change to test/js/node/worker_threads/worker-shutdown-post-leak.test.ts: adds an explicit 90_000 per-test timeout as the third argument to test.skipIf(...)(...), plus a four-line comment explaining why. No src/ changes, no assertion changes, no test logic changes.
Security risks
None. This is a test timeout value in an ASAN-only guard test. No runtime code, no user-facing surface, no inputs handled.
Level of scrutiny
Low. The diff is +5 lines (a numeric literal and a comment). The main review question is whether raising a timeout is papering over a real problem — REVIEW.md flags "don't raise per-test timeouts to make a slow test pass; shrink the workload." The PR description addresses this directly with timing probes: the scenario is already the minimum reproducer (one worker, two stdout writes), and the ~5-7s cost under debug+ASAN comes from worker VM boot/teardown plus LSan symbolizing against a ~1GB debug binary. Neither can be reduced by the test. The 5s default was the defect, not the test.
Other factors
- Verified the two sibling LSan guard tests cited in the PR (
shell-worker-terminate-leak.test.tsline 47,spawn-stdin-pipe-fd-leak.test.tsline 137) both use exactly90_000with near-identical justification comments, so this is convergence on an established pattern. - The PR notes the explicit timeout overrides CI's
--timeout=270000, dropping the CI budget from 270s to 90s — still ~200x the 442ms measured median, so this tightens rather than loosens the CI-side bound while fixing localbun bd testruns. - The comment satisfies REVIEW.md's "a literal sleep/setTimeout of 50ms or more … needs a comment naming why" spirit for timeout choices — it names both the pass-path cost (worker boot + VM teardown) and the fail-path cost (LSan symbolization), which is exactly what a future reader would otherwise spend time re-measuring.
- No prior reviews on the PR; nothing outstanding to address.
|
This PR may be a duplicate of:
🤖 Generated with Claude Code |
|
Not a duplicate in purpose, but the overlap is real: #38164 fixes a different leak (the worker thread's This PR predates #38164 and is test-only, so it can land on its own. If #38164 lands first, this PR becomes unnecessary and should be closed; if this one lands first, #38164 only needs to rebase that hunk. |
Problem
test/js/node/worker_threads/worker-shutdown-post-leak.test.ts(ASAN-only, added in worker: mark the context terminating before the final concurrent-queue drain #34278) fails withthis test timed out after 5000ms.when run withbun bd teston a debug+ASAN build on a busy machine.BUN_DESTRUCT_VM_ON_EXIT=1teardown takes 4.7 to 7.1s under debug+ASAN here (load average 120 to 170 on a 12 CPU cgroup), so the file's 5s default per-test timeout has no headroom. Same binary, empty-e 0: 0.3 to 0.5s.detect_leaks=0, 5.3 to 5.5s with the report). The test is watching for two allocations (ConcurrentTask + EventLoopTask), so a real regression would also be reported as a timeout, with the subprocess killed before the LSan report reaches the failure output.--timeout=270000on the asan lane, where this file's median is 442ms (test/expected-durations.json). The 5s default only applies to directbun bd testruns, which is where this flaked.Fix
90_000per-test timeout, with a comment saying why.test/js/bun/shell/shell-worker-terminate-leak.test.ts,test/js/bun/spawn/spawn-stdin-pipe-fd-leak.test.ts), for the same reason.--timeout(verified), so on CI's asan lane the budget goes from 270s to 90s, still about 200x the measured median, and a real leak regression still fails the test there, now with the LSan report attached.bun bd test test/js/node/worker_threads/worker-shutdown-post-leak.test.tstimed out at 5008ms before the change on this machine; after it, three runs pass in 6.2s, 6.8s and 7.1s. Test-only change, nosrc/changes.Background
ASAN_OPTIONS=detect_leaks=1andBUN_DESTRUCT_VM_ON_EXIT=1(tear the VM down fully at exit instead of calling_exit), so anything still allocated at exit is reported by LeakSanitizer as a leak and turns into non-empty stderr and exit code 1. The leak under guard here is the one fixed in worker: mark the context terminating before the final concurrent-queue drain #34278: a cross-thread task posted to a worker during its shutdown was enqueued onto a queue that is never drained again.test(name, fn, ms)sets the budget for that one test and takes precedence over the file default (5s) and overbun test --timeout, which CI uses to set the default per lane.Timing probes (debug+ASAN build of b7a0431, linux-x64, load average 120 to 170)
Scenario cost, three runs each, same env as the test:
Where the time goes (stderr timestamps relative to
new Worker):require("worker_threads")alone is ~1.3s, the worker'sonlineevent fires at +2.5 to +3.0s,exitat +3.1 to +3.8s. Release build of the same scenario: 0.08 to 0.10s total.Failure-mode cost: a C function compiled with
bun:fficcthat mallocs three blocks and drops them, called from asetTimeoutso the stack is not covered bytest/leaksan.supp, run with the test's env:bun bd teston the unmodified file:(fail) ... [5008.10ms] this test timed out after 5000ms.With this change:(pass) ... [6249.80ms],[6762.09ms],[7056.25ms].