Repository navigation
ci(bun): restore the worker idle memory limit and end a Bun worker from itself - #21646
Conversation
The limit bounds each worker thread's heap; without it the suite grows until the runner is out of memory. Dropping it in #21629 traded Bun's segfault for an OOM.
Bun segfaults when jest terminates a worker thread from the parent on an idle-memory restart, a different wild address each time and workers_terminated short of workers_spawned. Sending the end message jest already uses for shutdown lets the worker leave on its own. Guarded on Bun, so Node and Deno still terminate. Reproduced with a low limit: terminate crashes 5/5, ending 3/3 passes.
|
|
This PR is packaged and the instant preview is available (6412396). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@6412396
yarn add -D webpack@https://pkg.pr.new/webpack@6412396
pnpm add -D webpack@https://pkg.pr.new/webpack@6412396 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21646 +/- ##
==========================================
- Coverage 94.26% 94.25% -0.01%
==========================================
Files 628 628
Lines 80106 80106
Branches 23711 23711
==========================================
- Hits 75512 75506 -6
- Misses 4594 4600 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Generated code sizeComparing
1 asset(s) changed size
1 runtime(s) changed which runtime modules they carry
Built |
|
Warning Review limit reached
Next review available in: 39 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: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
WalkthroughThe Bun test script now enforces a 512MB Jest worker memory limit. The Jest worker patch makes Bun workers self-terminate through a child-end message while other runtimes retain direct termination. Bun workers also load 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.github/workflows/test.yml (1)
338-340: 🩺 Stability & Availability | 🔵 TrivialRequire a green result for the complete runtime matrix.
The Bun leg now depends on both applied patches and the new worker lifecycle. Require every workflow job to pass, including the Bun and Deno matrix entries. If a job fails, reproduce only the named case from its log.
As per coding guidelines,
.github/workflows/**/*is authoritative and every check must finish green.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e4848158-3f2d-4ee5-91e6-1dbe0718d799
📒 Files selected for processing (3)
.github/workflows/test.ymlpackage.jsontest/patches/jest-worker+30.4.1.patch
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
webpack/schema-utils(auto-detected)webpack/tapable(auto-detected)
Merging this PR will improve performance by 51.81%
Performance Changes
Tip Curious why this is faster? Comment Comparing |
Ending a worker only removes its message listener; the thread leaves only if that was its last handle. A jest worker that leaked one therefore stayed alive in the RESTARTING state forever — reproduced with a worker holding a timer: the idle-memory limit tripped (1.63 MB over a 1 MB limit), the restart was requested, and the next task still ran on the same thread. The limit had become a no-op for that worker, which is the one thing it exists to do. The worker now exits itself after teardown, on Bun only. Same reproduction: the state returns to `ok` and the next task runs on a new thread.
Summary
#21629 stopped the Bun job's segfault by dropping
--workerIdleMemoryLimitfromtest:base:bun, which was the wrong fix: the flag is what bounds the worker heaps, and without it the full suite OOM-kills the runner. This restores the flag and fixes the actual cause —jest-worker's idle-memory restart callsthis._worker.terminate()from the parent, and Bun 1.3.14 segfaults in thread teardown (a different wild address each run, withworkers_terminatedshort ofworkers_spawned). The patch has the worker end itself instead, which is a no-op off Bun.What kind of change does this PR introduce?
ci
Did you add tests for your changes?
No — the change is the Bun CI job's own configuration and its
test/patches/jest-worker+30.4.1.patch; the Bun job is the test.Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
AI (Claude Code) was used to diagnose the segfault down to the
terminate()call, write the patch hunk and the workflow comment, and rebase the branch. Every claim was checked against a local Bun run before being written down; the memory half can only be judged by CI, since this sandbox walls at ~15.1–15.5 GB on the full Bun suite in every configuration including unmodifiedmain.Generated by Claude Code
Summary by CodeRabbit