Repository navigation
Description
Found while repairing the scf-core suite (see the PR that fixes its load failures).
What happens
A full run of scf-core dies with a JS heap OOM — SIGABRT, not test failures:
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL Command was killed with SIGABRT (Aborted):
vitest run --config packages/scf-core/vitest.config.ts
Reproduced at both --max-old-space-size=4096 and 8192. Zero assertions fail before it
dies; the process just runs out of heap partway through.
Why
vitest.config.ts uses pool: "threads" (line 255) with maxWorkers: 2. Threads share a
heap, so nothing is reclaimed between the 329 test files — memory accumulates across the
whole run. The comment on line 256 ("Cap workers to 2 to prevent OOM on 14-CPU machines")
shows this has been fought before; capping workers reduced the pressure without removing
the cause.
The suite got heavier recently, legitimately: three assessment-wizard files used to abort
on import and cost nothing, and now render real component trees. That accelerates the OOM
but did not create it.
Why it has stayed invisible
scf-core is excluded from every aggregate command, so nothing ever tries to run it whole:
package.json:12—affected:test --exclude=…,scf-corepackage.json:158—test:unit --exclude=…,scf-corescripts/prepush.sh:32—TEST_EXCLUDES="…,scf-core,scaffald"
This is the blocker for dropping those exclusions. A suite that cannot complete cannot gate
merges, and un-excluding it as-is would trade an invisible problem for a permanently red
check — the same failure mode as the 80%-vs-37% coverage threshold removed in #492.
Suggested fix
Try pool: "forks" for this project. Each file gets a fresh process and its heap is
reclaimed on exit. Slower per file, but bounded. Was mid-verification when this was filed:
pnpm exec vitest run --config packages/scf-core/vitest.config.ts --pool=forks --maxWorkers=2(Note --poolOptions.forks.maxForks is not a valid CLI flag in vitest 4 — it fails with
CACError: Unknown option. Set pool options in the config file, or use --maxWorkers.)
If forks alone is not enough, the next step is finding which file leaks — OrganizationForm.test.tsx
is already excluded in packages/scf-core/vitest.config.ts for an "infinite render loop → OOM
after 5 min", so there is precedent for a single file being the cause.
Acceptance
pnpm exec nx run scf-core:test completes and reports a result, then scf-core is removed
from the three exclusion lists above so the suite actually gates merges.
Gotcha for whoever picks this up
When the run aborts, the JSON reporter leaves the previous run's file behind at
tests/reports/coverage/test-results.json. Reading it after a crash gives a plausible-looking
but stale result (I was briefly fooled by a "56 tests, 0 failures" that belonged to an earlier
run). Delete the report before each run.
Activity
thinkclay commentedon Jul 30, 2026
pool: 'forks'fixes it. Confirmed — the suite completes for the first time:A real result instead of a SIGABRT. Rolling the config change into the scf-core repair PR, so
the "suite can complete" half of this issue is handled there.
What this issue should now track: the 31 remaining failures
They are genuine assertion failures, not infrastructure. Top clusters:
features/discover/components/__tests__/UserProfilePanel.test.tsxfeatures/discover/components/__tests__/MapSearchInput.test.tsxfeatures/office/teams/components/__tests__/TeamForm.test.tsxfeatures/riasec-assessment/RIASECAssessmentWidget.test.tsxfeatures/occupation-assessment/OccupationAssessmentWidget.test.tsxMapSearchInputis worth a closer look: it passed when run in a small group during therepair work and fails in the full run, which points at cross-file state leakage rather than a
broken assertion. Forks isolate per file, so this is more likely shared module-level state or
an unreset mock than pool behaviour.
Un-exclusion still blocked, and that is deliberate
scf-corestays in the exclusion lists (package.json:12,package.json:158,scripts/prepush.sh:32) until these 31 are green. Removing them now would make every mergered — the failure mode #492 removed with the 80%-vs-37% coverage threshold. The suite being
runnable is the prerequisite; being green is what earns the gate.
Note on cost
Forks are slower than threads — a full run is several minutes. That is fine for a suite that
previously could not finish at all, but it is an argument for keeping
scf-coreonnx affectedrather than running it whole on every push once it is un-excluded.fix(test): run scf-core on the forks pool so the suite can complete
fix(test): make the scf-core suites load, run, and complete (#507)
test: run scf-core in the default suite (#593)
test: make the profile suites actually run (#592, #593) (#604)
fix(test): revert the scf-core un-exclude — the suite still cannot ex…
thinkclay commentedon Aug 12, 2026
Confirmed still reproducing on main as of 2026-08-12, with a sharper diagnosis than the original report.
I briefly claimed this was stale and un-excluded scf-core in #604. That was wrong — I had grepped a background task's output file for the OOM string and got nothing, because that file held only my own echo lines while vitest's stderr went elsewhere. Reverted in #606.
What actually happens
success--max-old-space-size=4096--max-old-space-size=8192Three things worth pulling out:
success: truein both runs. Nothing is failing; the process is dying.pool: 'forks'is already inpackages/scf-core/vitest.config.tsand each worker's heap goes away when it exits. What grows is the main process.So the tractable target is whatever the parent retains per file across 143 files. Candidates worth measuring, in rough order of suspicion: the json reporter accumulating every assertion result (
reporters: [..., ['json', { outputFile: ... }]]in the root config), the v8 coverage map merge, and the transform cache for the module graph.Until that is fixed, scf-core cannot be in
test:unitoraffected:test, which keeps #593 open.thinkclay commentedon Aug 12, 2026
Bisected this today. Three hypotheses ruled out, and there is now a deterministic 7-minute reproducer instead of a 15-minute one.
Reproducer
Reproduced on every attempt. Neighbouring shards are clean, which makes A/B testing a fix cheap:
Ruled out
Not the json reporter.
--reporter=dotwith no json output still OOMs. (It does give clean numbers: 139 passed | 3 skipped of 143 files, 978 assertions.)Not a single heavy file. The obvious suspects in the failing shard —
OccupationAssessmentWidget,OccupationAssessmentWizard,RIASECAssessmentWidget,RIASECAssessmentWizard— each pass alone, fast. So doesno-duplicate-vi-mock, which walks the tree.Not raw file count. 24 files pass in 7s; a different 12 files OOM after 452s.
The strongest signal
Tests execute in 4.68 seconds. The other ~440 are the parent process mark-compacting against the 4GB ceiling — it is thrashing, not working. Combined with
pool: 'forks'already isolating each file's own heap, that points at what the parent retains per file: the Vite module graph / transform cache for these particular dependency trees (react-native-web, charts, svg), not anything the tests themselves allocate.Raising the ceiling does not help — at 8192 it gets further and dies anyway, and dies sooner in relative terms once more files collect successfully.
The 12 files in the failing shard:
vitest list --config packages/scf-core/vitest.config.ts --shard=3/12.Keeps #593 blocked.
fix(test): the scf-core OOM was one typo'd vi.mock path (#504, #593) (#…
fix(seeds): seed-prod-safe was not reference-only (#504 follow-up) (#612