Repository navigation
Description
Problem
One run of the packages/codev unit suite (npm test, which is porch's tests check) takes an 18-core Mac from a one-minute load average of about 8 to about 59. Under that load the suite's own process-spawning tests miss their 5-second timeouts, so the check fails on tests that have nothing to do with the change under test. GitHub's runners pass the same suite every time.
Evidence (2026-11-17 to 2026-11-23, macOS, 18 cores)
- A builder ran the check three times on one branch. The third run started at load 7.7 with every other builder on the machine idle, and ended at load 59. Earlier runs saw 44, and 20 to 30.
- Another builder failed it four times the week before; each run failed a different unrelated test.
- Two more builders saw one-off failures on the same day, at loads of 24 to 35.
- The failing files are always from the same spawn-heavy set, and each passes when run alone:
bugfix-1267-launch-loop,ide-command,pir-1233-session-launch-loop,agy-auth-cache,tripwire-wiring,windows-console-spawn-guard,claude-cli-lane,bugfix-1754-dotenv-auth,doctor,bugfix-1455-pr-create-concept. In a failing run they take 15 to 48 seconds each, against a few seconds alone. - The same commits are green on GitHub, 8 of 8 checks, with those files passing.
What is not known
vitest.config.ts sets pool: 'forks' with singleFork: true, so test files should not be running in parallel. Something still produces a load of 59. Candidates, none confirmed:
- tests that spawn real child processes (shells,
git, fake CLIs, shellpers) and leave them running, or spawn many at once; singleForknot applying as intended on the installed vitest (4.x), so files do run in parallel;- coverage, type-checking or a build step running alongside;
- a filesystem-event storm from temp directories (this machine has a history of
fseventsdand Spotlight load).
Asked for
- Find the cause. One instrumented run: sample the process table through the run (count and command of live descendants of the vitest process, per second), record per-file wall time, and identify which files account for the load. A full run loads the machine for several minutes: get the owner's go-ahead before running it, and run it once.
- Fix it at the cause: leaked children reaped, spawn-heavy files serialised or bounded, or the pool setting corrected. Do not raise timeouts as the fix, and do not skip the tests.
- A check that would catch a regression: for example, a test-run teardown that fails when child processes outlive the suite.
Related
- Issue porch: machine-wide lock for heavy checks so concurrent builders stop saturating the machine #1892 (a machine-wide lock for heavy porch checks). It stops two builders overlapping. It does not help here: one run alone is enough.
- Issue Flaky: session-manager real-shellper tests use fixed wall-clock deadlines that fail under full-suite load (CI-skipped, so only local/porch runs see them) #1800 (real-shellper tests with fixed wall-clock deadlines that fail under full-suite load).
- Issues Flaky test: agy-auth-cache '#1077 re-probes after unauth TTL lapses' races TTL against process-spawn latency #1435, Flaky test: agy-auth-cache unauth-TTL re-probe races the 50ms TTL on slow CI runners #1460 and flaky test: agy-auth-cache 're-probes after the unauth TTL lapses' races its own 50ms TTL on slow runners #1596 (the
agy-auth-cacheTTL race on slow runners), and issue tests: load-dependent failures in the packages/codev suite on a native Windows dev machine (agy-auth-cache EPERM, metrics-model-id barrier, windows-job census, worker exit) #1923 (load-dependent failures on native Windows).
Until this is fixed
By owner ruling, a builder whose local full suite fails only on tests unrelated to its change, each passing alone, may let GitHub's green run on the same code stand in for porch's local tests check for that phase. This issue is what retires that rule.
Activity
waleedkadous commentedon Nov 23, 2026
Three more data points from 2026-11-23, same machine:
testscheck fail at load 23 to 27, then pass on an immediate rerun of the same commit; its own full run of that commit also passed (8494 tests). Second time on that project.porch doneprints only the first lines of a failed check (npm warnings) and keeps no copy. That is the open issue "porch done truncates failing check output; the failing test is never named" (porch done truncates failing check output; the failing test is never named #1853). It makes this issue harder to diagnose: the evidence of which spawn-heavy test timed out is lost on every porch-run failure. One builder recovered the names from vitest's results cache instead.For whoever takes this: fixing #1853 first, or at least having porch write the failed check's full output to a file, would turn every future load failure into a data point.
waleedkadous commentedon Nov 23, 2026
A lead on the cause, observed twice on 2026-11-23 while a single builder's suite was running (load 33, 18 cores):
fseventsdat about 88% andXprotectServiceat about 47 to 80%, alongside a stream ofnodeprocesses each 0 to 4 seconds old.doctor, forge,claude-cli,ide-*, launch-loop).Hypothesis to test first: the suite starts a very large number of short-lived
nodeprocesses and writes many files under temp directories. On macOS each new process launch is checked by XProtect and each file event goes throughfseventsd, so the cost is in the operating system, per spawn and per file, and does not show in the tests' own CPU time. That would also explain why GitHub's Linux runner is unaffected. Things to measure in the instrumented run: process launches per second, file events per second, and whether the temp roots sit somewhere a file watcher (Spotlight, an editor, Tower's own watchers) is observing.waleedkadous commentedon Nov 24, 2026
Probable root cause found: the suite's single-fork setting has been a no-op since the Vitest 4 upgrade.
packages/codev/vitest.config.tssays:The installed Vitest is 4.1.4 (
"vitest": "^4.0.15", in since 2025-12-11). Vitest 4 removedpoolOptions. Verified here, not from memory:DEPRECATED `test.poolOptions` was removed in Vitest 4. All previous `poolOptions` are now top-level options. Please, refer to the migration guide: https://vitest.dev/guide/migration#pool-reworkvitest/distcontains no reference tosingleForkat all.os.availableParallelism().So the suite does not run in one fork. It runs as many test files at once as the machine has cores: 18 on the affected Mac, 4 on GitHub's
ubuntu-latestrunner. That fits every observation in this issue: one run alone takes the Mac to a load of 30 to 59, the tests that time out are the ones that start subprocesses, they pass when run alone, and the Linux runner is green every time. Thefseventsd/XprotectServiceload I reported above is then a consequence (18 files' worth of process launches and temp files at once), not the cause.It also explains why porch's truncated output (#1853) shows "npm warnings" first: that deprecation line is among the first lines printed.
Not yet verified: that capping the workers makes the suite pass on this machine. That needs one full run with a cap.
Suggested fix (small):
poolOptionsblock with the Vitest 4 top-level options, following the migration guide. Check the option names against the installed version, not memory. Decide the cap deliberately:1restores what the comment intended; a small fixed number such as4matches the CI runner and is much faster.packages/andapps/by a grep forpoolOptionson 2026-11-24, butvitest.e2e.config.tsandvitest.cli.config.tsshould be read for their own parallelism settings).waleedkadous commentedon Nov 24, 2026
Scope for the fix (BUGFIX). The owner has approved one full local run of the suite with the worker cap in place, as the verification; no other full local runs.
poolOptionsblock inpackages/codev/vitest.config.tswith Vitest 4's top-level options. Read the migration guide and the installed version's types; do not rely on memory for option names. Confirm the deprecation line no longer prints.vitest.e2e.config.ts,vitest.cli.config.tsand the other packages' vitest configs for the same dead block or for missing caps, and fix what you find.Out of scope: splitting the suite into clusters, raising test timeouts, skipping tests.
waleedkadous commentedon Nov 24, 2026
On it! Working on a fix now.
[Bugfix #1956] Fix: cap vitest at 3 workers; the singleFork setting w…
[Bugfix #1956] Test: each packages/codev vitest config resolves to a …
[Bugfix #1956] Thread: investigation, fix and verification-run results