fix(run): wait for the runner's count before the next test under --max-failures

BA
9h ago
+178-46

What and why

  • The scheduler is now the only owner of the failure count. RunUnitMessage.failureLimit is just a flag that the run has a limit; the snapshot ({ limit, failures }) and the worker's own countFailure arithmetic are gone.
  • While the run has a limit, a worker that reports a counted failure waits before its next test (TargetExecutorOptions.beforePair, also before each setup pair) until the runner answers. The answer is a new continue message when the run is still below the limit, or the existing interrupt with the failure-limit skip once it is reached. One round-trip per failure, no timing.
  • The worker counts the failure before it emits the result, because an in-process runner answers inside emit.
  • Patch changeset for e2e. No docs change: docs/reference/cli.mdx already describes the fixed behavior.

Issue

Fixes #1745

Verified

Ran it locally: yes

  • New 2-worker, maxFailures: 2 test in parallel-workers.test.ts: file a fails at once, file b fails 500 ms later, so b's worker trips the limit. It asserts the rest of the tripping file is skipped with failure-limit (no interrupted), and at most one interrupted overall. It fails 3 of 3 runs against a main build and passes 5 of 5 here.
mainthis branch
b next interrupted (started after the limit, then cancelled)b next and b last skipped, failure-limit
  • vitest run tests/unit: 3653 pass. vitest run tests/integration: 972 pass, 3 fail in cli-init.test.ts only because @e2e-dev/mobile was not built locally (same on main).
  • pnpm check green.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.