Repository navigation
Cut Git subprocess and copy work in Windows-flaky Git tests - #8073
Merged
Merged
Conversation
The remote-refresh, patch-format, default-branch, status-cache, and known-PR tests timed out on loaded Windows runners because each did more real Git process and fixture-copy work than its budget allowed under contention. Share one read-only remote, read user display settings from a global config file instead of a copied repository, build default-branch fixtures with one fast-import, split the status-cache test, and batch the two known-PR reads into one views call. Compare default-branch refs with one merge-base instead of two ancestry checks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gs use Every host test starts real Git and a Node fake gh through cmd.exe; on the plugins-2 Windows shard single-view neighbours take up to 2.7s and the known-PR test took 4.6s against vitest's 5s default. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
All of group A failed the same way: Windows test shards timed out on real Git subprocess tests. None of these tests or their code changed on main since their last failures (latest: main
9f3a35d930, 11-23). Each failure was a flake: other attempts on the same SHA or main passed. Passing Windows runs take 0.4–2 s per test, and failures need a 15–25x slowdown. Neighbouring tests in the same file ran 11–16 s in the same minute. So the cause is CPU/IO starvation on the 8-vCPU runner, which runs several vitest packages at once (turbo--concurrency). It is not a hang. On an idle Windows 11 VM, a git spawn costs about 60 ms, copying a.gittree about 50 ms, and a localgit fetch250–400 ms (it startssh.exe, upload-pack,rev-listandmaintenance --auto). Whether a test fails depends on how much of that work it does in one budget. Root cause per test:workspace-git-fetch› fetches and prunes only origin (interactive: true/false), skips … none named origin (16 + 1 failures): every case copied the repo plus one bare remote per remote, so 4.gittrees for the two "only origin" cases. The case with 2 copies never failed.git fetchalso startedgit maintenance run --auto.workspace-git› keeps the standard patch format under … (9 failures): every case copied the template twice and ran 8 patch reads plusgit configspawns. Half of that rebuilt the same unconfigured baseline each time.workspace-git› readDefaultBranchRefs (5 test failures, plus 1beforeAlltimeout at 10 s): thebeforeAllused 5 git processes, and the ahead/diverged cases rangit commit(plus its maintenance child). ProductioncompareBranchOidsthen ranmerge-base --is-ancestortwice.plugins/gitworkspace-status-cache › reuses committed comparisons across readers while refreshing edits and moved refs (7 failures): one test made 7 sequential status reads, 79 git processes in one 15 s budget, and it ran first in the file. The other status-cache failure in the evidence (11-16, "cancels an over-budget squash command", an assertion error) came before Stabilize desktop, Git, and parser CI tests #7680, which fixed that race, and it hasn't recurred. It is left alone.github-pr-status› reads a known PR by URL only on the branch it was found on (2 failures at the package's default 5 s): two sequentialviewscalls, each starting a fakegh(cmd.exe→node.exe) one after the other, plus 8 git processes.What changed
workspace-git-fetch.test.ts: all remotes point at the one read-only template remote. Fetching never writes to the remote, so a wrong fetch ofalpha/zetastill addsfreshand prunesstale, and the test still catches it. The template turns offmaintenance.auto. Each case now copies one repo instead of up to four.workspace-git.test.tspatch-format cases: the baseline is computed once inbeforeAll. Each case writes its settings to aGIT_CONFIG_GLOBALfile, the user's own config level, and reads the shared template's 4 patches in parallel. No repo copies and nogit configspawns. Baseline and cases both use a hermetic global file. With bb's display overrides removed, all 9 cases still fail.workspace-git.test.tsreadDefaultBranchRefs: the template isgit init --template=plus onegit fast-import, which writes main, origin/main, and the local and remote tip commits. Each relation case applies its moves with oneupdate-ref --stdin. The behind/ahead/diverged cases share one table and keep their names.workspace-git.tscompareBranchOids: onegit merge-base <local> <origin>replaces the two--is-ancestorchecks. If the merge base is local, local is behind; if it is origin, local is ahead; otherwise, or with no common ancestor (exit 1), they have diverged; any other exit is unknown. This is exact, because when A is an ancestor of B the merge-base set is {A}. It saves one git process for every ahead or diverged default-branch read and branch-ref resolution in production. The now-unusedisAncestorRefis removed.workspace-status-cache.test.ts: the kitchen-sink test becomes "reuses a committed comparison across readers while refreshing worktree edits" and "recomputes the comparison when HEAD or the base branch moves", with the same assertions. The feature branch is built withfast-import, and the template turns offmaintenance.auto. The largest single test drops from 79 to 50 git processes.github-pr-status/host.test.ts: both known-URL reads go into oneviewscall, as the client batches them. They share one batchedghprocess and their git reads run concurrently. The test asserts there is exactly oneresource(url:selection, onp0, and that the other read is aheadRefNamelookup.github-pr-status/vitest.config.ts:testTimeout: 15_000, the budget the git, github, docs and workflows plugins already use. This is the one budget raised, because the work is inherently slow on the slowest runner. Every test inhost.test.tsstarts real git plus a Node fakeghthroughcmd.exe, andplugins-2shares its runner with the environment plugins' 60 s-budget tests. On this PR's first Windows run, single-view neighbours took 1.6–2.1 s, the single-ghgit-hosttests up to 2.7 s, and the batched known-PR test 4.6 s. The 5 s vitest default is not enough headroom for any of them.No retries or CI settings changed.
How you verified
pnpm exec turbo run test typecheck lint --filter=bb-environment-provider-host --filter=bb-plugin-bb--git --filter=bb-plugin-bb--github-pr-status: 74 + 293 + 182 tests pass; typecheck and lint are clean (the git plugin's 9 lint warnings are existing ones inui/diff).MACHINE_READ_GIT_CONFIG's display entries fails all 9 patch-format cases; fetching--allfails both "only origin" cases; swapping the behind/ahead result fails the relation table; always reusing the known URL fails the PR test.gitPATH shim (top-level spawns only): patch-format case 10 → 4; "user Git settings" describe 100 → 57; status-cache test 79 → 41 / 50 after the split; PR test 2ghprocesses → 1. Fetch cases drop 3 directory copies and a maintenance child; spawn counts are otherwise unchanged.packages-other, none of the changedenvironment-provider-hosttests passed vitest's 300 ms slow-test threshold. This shard ran only the affected packages, so it was less loaded than a full main run.🤖 Generated with Claude Code