Repository navigation
fix(backend): run the test suite in forked processes so CI stops being OOM-killed - #975
Merged
Merged
Conversation
…g OOM-killed The backend suite boots ~530 PGlite instances across ~140 files. Under the threads pool every worker lives in one process, and on the Linux CI runner that process climbed past 16 GB near the end of the run and was SIGKILLed (exit 137) on main at 3b300e6, with no test failing. A forked worker hands its memory back to the OS when it exits, which the threads pool cannot do. Measured locally on the full suite at one worker: threads peaked at 2.6 GB and never dropped below 1.3 GB between files, forks peaked at 3.1 GB and returned to ~0.7 GB; neither pool leaks across files on macOS, so the growth is specific to the Linux allocator. Threads bought ~3s of wall time, which is not worth a red main.
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughVitest now runs backend tests in forked processes instead of worker threads. Other test settings remain unchanged. ChangesVitest pool configuration
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What broke
Main's CI went red on 3b300e6 with no failing test: the `test-packages` shard was killed with exit 137 while only `@maple/backend` was still running, ~4.5 minutes into a suite that normally finishes in ~4.7. The deploy gate then refused to ship. Re-running the job passed and the deploy went out, so this is a memory flake, not a regression from the commits above it (neither touches the backend package).
Why
The backend suite boots ~530 embedded PGlite instances across ~140 files. Under `pool: "threads"` every worker thread lives in the one vitest process, and on the Linux runner that process grew past 16 GB by the end of the run.
Measured locally on the full backend suite at one worker:
Neither pool leaks across files on macOS, so the runaway growth is specific to the Linux allocator holding on to memory freed by terminated threads. A forked worker hands everything back to the OS when the process exits, which threads cannot do. Threads were chosen for ~3 s of wall time on the full suite; that is not worth a red main.
Change
`packages/backend/vitest.config.ts`: `pool: "threads"` → `pool: "forks"`, `isolate` unchanged, comment updated with the evidence.
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit