Skip to content

Run git-config plugin install tests outside the concurrent suite - #7951

Merged
ymichael merged 1 commit into
mainfrom
bb/fix-flaky-plugin-install-git-fallback-test-git-c-thr_2nenrk8bjf
Nov 21, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/fix-flaky-plugin-install-git-fallback-test-git-c-thr_2nenrk8bjf

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Two tests added in #7911, "fetches only the resolved commit instead of the whole repository" and "falls back to a full clone when the server refuses to serve the commit directly", sit in the same describe.concurrent block of apps/server/test/services/plugins/plugin-install.test.ts. Each one configures git by writing GIT_CONFIG_COUNT/GIT_CONFIG_KEY_0/GIT_CONFIG_VALUE_0 into process.env, then restores the old values. The plugin service has no other way to receive git config: runInstallCommand spawns git with process.env. When both tests overlap, the shallow test overwrites GIT_CONFIG_KEY_0 (protocol.version becomes url.….insteadOf) or its restore deletes the variables. The fallback test's probe git fetch --depth 1 <repo> <sha> then runs over protocol v2, which serves any commit, so it succeeds. That produces the CI failure AssertionError: promise resolved "{ stdout: '', …(1) }" instead of rejecting seen on #7893 and #7869.

What changed

  • The two tests move into their own non-concurrent describe.skipIf(!hasGit)("git sources configured through the server process environment"), placed between the two concurrent suites. Vitest runs a non-concurrent sibling as its own group, after the preceding concurrent group finishes and before the next one starts (partitionSuiteChildren in @vitest/runner). So nothing else in the file runs while process.env holds their git config. Moving them out of "git sources" is required: describe.concurrent makes the suite itself concurrent, so "git sources" and "multi-plugin repositories" run in parallel, and test.sequential inside "git sources" would still overlap the other suite.
  • The probe git commands (git clone and git fetch) get their config through the child env option (gitConfigEnv) instead of process.env. withProcessGitConfig now wraps only the service.install call, which has no other config channel.
  • Nothing else in the file mutates process.env inside a concurrent block. The npm-config tests sit in sequential describes, and the file already gets an isolated worker because it mutates process.env.

Test-only change; production code is untouched.

How you verified

  • Reproduced on main by running only the two tests, so they always overlap: vitest run test/services/plugins/plugin-install.test.ts -t "fetches only the resolved commit|falls back to a full clone" failed 15/15 runs with the exact CI error (the fetch printed * branch <sha> -> FETCH_HEAD).
  • Same command with this change: 20/20 passed.
  • Full file, 8 consecutive runs: 8/8 passed (64/64 tests each).
  • pnpm exec turbo run typecheck --filter=@bb/server and pnpm exec turbo run test --filter=@bb/server -- test/services/plugins/plugin-install.test.ts both passed.

AGENT GENERATED

🤖 Generated with Claude Code

The shallow-fetch and full-clone-fallback tests both configure the
plugin service's git through GIT_CONFIG_* in process.env. They ran in
the same describe.concurrent block, so one test's config overwrote or
restored away the other's, and the fallback probe fetch succeeded over
protocol v2. Move both into a non-concurrent describe so vitest runs
them while no other test in the file is running, and pass the probe
commands their config directly through the child env.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 4e45c9b into main Nov 21, 2026
31 checks passed
@ymichael
ymichael deleted the bb/fix-flaky-plugin-install-git-fallback-test-git-c-thr_2nenrk8bjf branch November 21, 2026 00:30
ymichael added a commit that referenced this pull request Nov 24, 2026
## Human comments

## What was wrong

These are the still-active group D server flakes from the past week.

**`test/environments/locate.test.ts`**: "lets two Local threads share
one row" and "holds a second branch switch behind the first one's
claim…". This failed 3 times on Windows server-2, including main
`de0b6f1ccf` and today on `f9134e1c49`. Both tests always fail together,
and attempt 2 passed on the same SHA.

- `path-admission.ts` set `PATH_CLAIM_SETTLE_TIMEOUT_MS =
ENVIRONMENT_HOOK_TIMEOUT_MS` at module top level, importing the value
from `environment-hooks.ts`.
- `environment-hooks` sits on an import cycle that leads back to
`path-admission` (through `hosts/online-rpc` → `ws/hub` → … →
`threads/thread-command-environment`).
- Node test files share a worker (`isolate: false`). When a file such as
`test/app/host-shared-ports.test.ts` loads that graph from a different
entry, `path-admission` is evaluated before `environment-hooks`
finishes, and the constant is `undefined`.
- Both settle waits (`admitAfterPathClaimsSettle` and
`pathClaimDeadline` in `thread-provisioning.ts`) then compute a `NaN`
deadline. A thread that should wait behind another thread's settling
path claim either fails immediately (`'error'` instead of `'starting'`)
or never wakes (`[id, null]`).
- These two tests are the only ones in the file that wait on a settling
claim, which is why they fail as a pair.
- The production bundle orders the two `var`s safely today, but it would
get the same silent `NaN` if the bundle order changed.

**`test/server-move/coordinator.test.ts` (3 tests) and
`test/server-move/routes.test.ts` (1 test)** failed once on Windows
server-3 (run 44836680494). Attempt 2 passed on the same SHA, and that
branch only touched `install-machine.sh`.

- Each failing `expect.poll` used vitest's default 1 s budget while
waiting for the coordinator to get through real work: a real export of
the harness DB (SQLite backup, tar.gz, sha256), target RPCs, and the
200–300 ms activation retry windows the tests configure.
- On a passing Windows attempt the coordinator file takes 4.9 s, and the
"abandons…" test takes 624 ms. On the failing runner the whole file took
17.3 s, about 3.5× slower, which puts these paths at roughly 2 s, past
the 1 s budget.
- That work is inherently that slow on the slowest runner, so the budget
is raised rather than the work faked.

Checked and left out:
- **plugin-install "falls back to a full clone…"** (13 failures) and the
ubuntu "refuses a collection entry…" failure (same probe, reported
against a test running alongside it): fixed by #7951. The last failure
was 11-21 00:08 UTC, before #7951 merged at 00:30 UTC. #7951's own repro
passes 10/10 on current main.
- **plugin-install ENOENT on "resolved commit / pinned sha" tests**: the
cache path contains `127.0.0.1:<port>`, and Windows rejects a colon in a
path. This is deterministic and only on unmerged #7914.
- **plugin-install "Filename too long" on range-spec tests**: open #7882
moves test temp dirs under a deeper `bb-vt-` sandbox, which pushes git
object paths past Windows MAX_PATH. This is deterministic and only on
that branch.

## What changed

- `apps/server/src/services/environments/environment-hook-timeout.ts`
(new, no imports) owns `ENVIRONMENT_HOOK_TIMEOUT_MS`.
`environment-hooks.ts` and `path-admission.ts` import it from there. A
module with no imports always finishes evaluating before its importers,
so the settle deadline no longer depends on module load order. Behavior
is otherwise unchanged (still 15 minutes).
- `apps/server/test/helpers/server-move.ts` exports
`SERVER_MOVE_STEP_POLL = { timeout: 10_000 }`.
- Every `expect.poll` in `coordinator.test.ts` and `routes.test.ts` uses
it, since each one waits on the move pipeline.
- 10 s gives about 4× headroom over the ~2.2 s observed on the slow
runner and stays under the 15 s test timeout.
- Passing runs are unaffected; only a real failure takes longer to
report.
- No wire, CLI or doc changes.

## How you verified

- **locate, reproduced locally.** A temporary vitest sequencer ran the
failing shard's 115 shared-worker files in one worker, with locate last.
  - Both tests failed with the exact CI messages.
- Bisecting narrowed it to `test/app/host-shared-ports.test.ts`. Its
imports alone are enough (`-t KT2`, with all its tests skipped).
- Logging `PATH_CLAIM_SETTLE_TIMEOUT_MS` inside locate printed
`undefined` in that order.
- Forcing `settlingPathClaim()` to return null reproduces exactly these
two failures and no others.
- **locate, before and after,** with host-shared-ports then locate in
one worker:
  - main: **5/5 runs fail** (2 failed | 20 passed).
  - this branch: **5/5 runs pass** (22/22).
- The full 115-file single-worker order passes on this branch: 113
files, 953 tests.
- **locate, Windows CI evidence.** A diagnostic push of this PR ran both
tests 30× each on Windows server-2, and all 60 iterations passed. That
rules out an in-test race and points to worker history.
- **server-move.** I injected 800 ms of latency before the real export
(about the failing runner's 3.5× slowdown on top of the export itself):
- main: **4 failed | 25 passed**. Failing: "abandons a move in
recovery_required…", "rolls back when the target is gone…", and two
sibling recovery tests in the same class.
  - The 4 CI-failing tests alone failed 2/4 in each of 3 runs.
  - this branch: **29/29 in 3/3 runs**.
  - Without injected latency, 29/29 pass.
- `pnpm exec turbo run typecheck --filter=@bb/server` passes.
- `test/environments`, `test/server-move` and
`test/threads/thread-environment-restore.test.ts`: 23 files, 175 tests,
all pass.

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant