#13357

[Bug] Test-harness CPU saturation and sandbox poll-retry storms (expect.poll EPERM retries, direct vitest scripts, unbounded oxlint threads, swiftc/tsx concurrency)

Openmorlutoopened 3d ago

Before submitting

  • I searched the open and closed issues for a related report.
  • I removed credentials, tokens, private paths, and sensitive target data.

Area

Other

Observed behavior

When running Vitest tests or linters locally—especially under macOS Seatbelt sandboxing where /bin/ps or compiler caches return EPERM—the test harness and static-check orchestration exhibit two distinct failure/amplification modes (partly observed on local macOS runs with leaked setInterval test stubs, partly source-derived from Vitest and test-runner inspection; see separate surgical leak fix PR on fix/test-process-group-cleanup):

  1. Systemic expect.poll retry storms on terminal inspection failures:
  2. Direct vitest run npm scripts bypass run-exclusive.mjs and detached: true children escape POSIX PGID signaling:
    • package.json:165-189 (test:run, test:boundary, test:mcp, test:acceptance, test:integration, test:coverage) invoke vitest run directly without scripts/run-exclusive.mjs --unlocked.
    • Meanwhile, scripts/run-exclusive-command.mjs:161-164 signals -process.pid on interrupt/disconnect, which cannot reach detached: true provider children spawned by src/process/ProviderProcess.ts:395 if a Vitest worker is killed before test finally hooks execute. Note that unconditionally wrapping package.json vitest scripts in run-exclusive.mjs would require WindowsOwnedProcess (native/windows/build/rea-windows-x64.node) on win32 source tests unless platform-gated like scripts/run-development-tests.mjs.
  3. Unbounded oxlint thread pool in npm run lint:
    • scripts/ci/static-check-report.mjs:83-87 pins --threads 1 only when typed is true (lint:typed), leaving untyped oxlint (package.json lint) uncapped across all host cores alongside concurrent Vitest/tsrs runs.
  4. Heavy inner-subprocess workloads and remaining setInterval test stubs:
    • Tests spawning direct xcrun swiftc (darwinProcessRunTokenReader.test.ts), cache-bypassing REA_DARWIN_MODULE_CACHE_PATH setups, 32–36 MiB tsx heap children (tests/boundary/providers/desktopZipHeap.test.ts, desktopStateHeap.test.ts), the byte-by-byte bash truncation loop (tests/boundary/filesystem/installScript.test.ts:288-340), and additional setInterval(() => {}, 1000) test suites outside the fix/test-process-group-cleanup PR (src/adb/AdbCommand*.test.ts, tests/boundary/process/providerOutcome.test.ts, tests/boundary/process/ownedCommand.test.ts, tests/boundary/providers/adb/adbCommandFinalization.test.ts, tests/boundary/providers/hopper/hopperClient.*.test.ts) can saturate CPU or leak stubs if interrupted under --unlocked.

Reproduction

  1. Run expect.poll tests that invoke observePosixProcess or host.listProcesses() inside a macOS Seatbelt sandbox where /bin/ps returns EPERM (or inspect node_modules/vitest/dist/chunks/index.C4tKZ0yW.js showing try { ... } catch retry behavior).
  2. Inspect package.json:165-189, scripts/run-exclusive-command.mjs:161-164, and scripts/ci/static-check-report.mjs:83-87.

Note: Live unsandboxed/sandboxed timing benchmarks for all suites above were not all executed in full; processCli.test.ts, FirmwareCommand.test.ts, and PCAP/native cleanup suites were reproduced directly and targeted in a separate surgical PR.

Expected behavior

  • Test polling helpers fail fast when inspection returns a terminal capability/permission error (EPERM / "unavailable") instead of retrying for 25s–270s, without weakening observePosixProcess.ts or ProcessOwnership.ts fail-closed production invariants.
  • Direct POSIX Vitest runs supervise or reap child process groups reliably without breaking Windows zero-addon source tests.
  • oxlint honors bounded worker concurrency consistent with vitest.config.ts and run-typescript.mjs.

Impact and scope

High local CPU saturation and test-hang amplification under macOS Seatbelt sandboxing or concurrent local runs; potential orphaned setInterval stub processes if Vitest workers are killed mid-test outside finally/onTestFinished cleanup. Does not weaken production ownership checks.

REA version

9a6ee71886 (origin/main)

Runtime and platform

Node v24.22.1; macOS arm64 (Seatbelt sandbox & local CLI)

Target and artifact context

Test suites and CI/lint runner scripts (tests/, scripts/, package.json)

Interface

Other

Earliest failure stage

Cleanup, cancellation, or lifecycle

Relevant output or evidence

Source locations verified directly at 9a6ee71886:

  • tests/boundary/process/darwinProcessRunTokenReader.test.ts:1577-1584
  • tests/boundary/providers/GdbSessionReviewRegressions.test.ts:501,633,1022
  • src/apktool/ApktoolVersionProbe.lifecycle.test.ts:34-60
  • tests/boundary/providers/apktoolProcessFixture.test.ts:56-64
  • tests/boundary/providers/apktoolDecodeDeadline.test.ts:40-52
  • src/process/DarwinHelperCache.ts:235-242
  • scripts/run-exclusive-command.mjs:161-164 and src/process/ProviderProcess.ts:395
  • scripts/ci/static-check-report.mjs:83-87 and package.json:165-189
  • tests/boundary/filesystem/installScript.test.ts:288-340, tests/boundary/providers/desktopZipHeap.test.ts, desktopStateHeap.test.ts

Typed outcome or recovery expected

Typed fail-fast test helper separating "still-running" from terminal inspection failure (EPERM / "unavailable").

Analysis or suspected cause

Source-derived analysis: Vitest expect.poll catches all exceptions (including assertion/inspection errors) and retries for the configured project poll timeout; observePosixProcess intentionally throws on EPERM so expect.poll spins instead of aborting early.

Additional context

Related issues/PRs (non-duplicate boundary):

  • #9198 & PR #9261 (production Seatbelt /bin/ps EPERM handling in analyze-javascript-application)
  • #13280 (production 20 Hz macOS ps polling and baseline/sweep scoping)
  • #10459 (pre-existing test suite failures)
  • Surgical leak-cleanup PR on branch fix/test-process-group-cleanup (reaps setInterval test stubs in finally/onTestFinished and fixes processCli.test.ts:200 fail-fast polling)

Activity

0

No activity yet.