Skip to content

tests: one run of the packages/codev unit suite takes an 18-core Mac from load 8 to 59, and its own spawn-heavy tests then time out #1956

Done

Description

@waleedkadous

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;
  • singleFork not 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 fseventsd and Spotlight load).

Asked for

  1. 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.
  2. 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.
  3. A check that would catch a regression: for example, a test-run teardown that fails when child processes outlive the suite.

Related

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

  1. added
    area/core
    on Nov 23, 2026
  2. waleedkadous commented on Nov 23, 2026

    @waleedkadous
    ContributorAuthor

    Three more data points from 2026-11-23, same machine:

    • A builder on a seven-phase project had porch's tests check 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.
    • In three of today's failures the builder could not name the failing test, because porch done prints 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.

  3. waleedkadous commented on Nov 23, 2026

    @waleedkadous
    ContributorAuthor

    A lead on the cause, observed twice on 2026-11-23 while a single builder's suite was running (load 33, 18 cores):

    • The top CPU consumers were not the tests. They were macOS system services: fseventsd at about 88% and XprotectService at about 47 to 80%, alongside a stream of node processes each 0 to 4 seconds old.
    • A later run failed 92 tests in 17 files, every one a 5-second timeout, all in subprocess tests (consult lanes, doctor, forge, claude-cli, ide-*, launch-loop).

    Hypothesis to test first: the suite starts a very large number of short-lived node processes and writes many files under temp directories. On macOS each new process launch is checked by XProtect and each file event goes through fseventsd, 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.

  4. waleedkadous commented on Nov 24, 2026

    @waleedkadous
    ContributorAuthor

    Probable root cause found: the suite's single-fork setting has been a no-op since the Vitest 4 upgrade.

    packages/codev/vitest.config.ts says:

    pool: 'forks',
    poolOptions: {
      forks: {
        singleFork: true,  // Prevent worker crash on CI during cleanup
      },
    },

    The installed Vitest is 4.1.4 ("vitest": "^4.0.15", in since 2025-12-11). Vitest 4 removed poolOptions. Verified here, not from memory:

    • Running a single test file prints: 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-rework
    • The installed vitest/dist contains no reference to singleFork at all.
    • The installed code takes its default worker count from 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-latest runner. 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. The fseventsd / XprotectService load 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):

    1. Replace the dead poolOptions block 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: 1 restores what the comment intended; a small fixed number such as 4 matches the CI runner and is much faster.
    2. One full local run with the cap, recording wall time, peak load and failures. Get the owner's go-ahead for that run.
    3. Check the other vitest configs in the repo for the same dead block (none found in packages/ and apps/ by a grep for poolOptions on 2026-11-24, but vitest.e2e.config.ts and vitest.cli.config.ts should be read for their own parallelism settings).
    4. Make the deprecation fail the build, or at least assert in a test that the resolved config has the intended worker cap, so a future major upgrade cannot silently undo it again.
  5. waleedkadous commented on Nov 24, 2026

    @waleedkadous
    ContributorAuthor

    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.

    1. Replace the dead poolOptions block in packages/codev/vitest.config.ts with 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.
    2. Choose the cap deliberately and say why in a comment: a small fixed number (start with 4, which matches GitHub's runner) rather than 1, unless the one verification run shows 4 still times out. An environment variable override for CI or a quiet machine is fine if it is one line.
    3. Read vitest.e2e.config.ts, vitest.cli.config.ts and the other packages' vitest configs for the same dead block or for missing caps, and fix what you find.
    4. A test that asserts the resolved config carries the intended cap, so a future major upgrade cannot silently undo it.
    5. The one verification run: record wall time, peak one-minute load and any failures, with and without nothing else running. Put the numbers in the PR. Before starting it, check the one-minute load is under 18 and tell the architect you are starting.
    6. If the capped run is green, say in the PR that the standing "GitHub's run stands in for the local tests check" rulings can be retired; that is the owner's call, not yours.

    Out of scope: splitting the suite into clusters, raising test timeouts, skipping tests.

  6. waleedkadous commented on Nov 24, 2026

    @waleedkadous
    ContributorAuthor

    On it! Working on a fix now.

  7. added 3 commits that reference this issue on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions