Skip to content

fix(backend): run the test suite in forked processes so CI stops being OOM-killed - #975

Merged
Makisuo merged 1 commit into
mainfrom
fix/backend-test-pool-forks
Sep 22, 2026
Merged

Makisuo merged 1 commit into
mainfrom
fix/backend-test-pool-forks

Conversation

@Makisuo

@Makisuo Makisuo commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

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:

pool peak RSS floor between files
threads 2.6 GB 1.3 GB
forks 3.1 GB 0.7 GB

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


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Tests
    • Test execution now runs in forked processes, improving test-runner compatibility while preserving existing test settings.

…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.
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 5354a325-fca8-43f1-94a4-4cc1842ac109

📥 Commits

Reviewing files that changed from the base of the PR and between 3b300e6 and 3cae65a.

📒 Files selected for processing (1)
  • packages/backend/vitest.config.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Vitest now runs backend tests in forked processes instead of worker threads. Other test settings remain unchanged.

Changes

Vitest pool configuration

Layer / File(s) Summary
Select forked test processes
packages/backend/vitest.config.ts
The Vitest test pool changes from worker threads to forked processes. The configuration comment describes process isolation behavior.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: using forked processes for backend tests to prevent CI out-of-memory termination.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

@Makisuo
Makisuo merged commit f75d503 into main Sep 22, 2026
35 checks passed
@Makisuo
Makisuo deleted the fix/backend-test-pool-forks branch September 22, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant