test: share the temp-repo teardown fix across the git fixtures - #95
Merged
Conversation
Follow-up to the ENOTEMPTY flake fixed in completeRunArtifacts: the same race — a detached `git maintenance run --auto` still writing into .git when the teardown removes the tree — was latent everywhere a test builds a real git repo in a temp dir. Add tests/helpers/tempGit.ts with the two halves of that fix: disableGitAutoMaintenance, so no background process outlives the test, and removeTempDir, whose retries cover any writer the config cannot reach (a clone made inside src/, say). Applied to the nine fixtures that create git objects, plus the e2e tempEnv helper, which commits and so carried the race for every e2e test. Every repo each one builds is covered: working repos, bare remotes, and mid-test clones. Not swept: six files (loadConfig, upgradeConfigSchema, initProject, cli/schemaUpgrade, repoRootedCli, loadConfigLayers) run `git init` and never commit. `init` creates no objects, so nothing spawns maintenance and there is no writer to race — touching them would be churn, not a fix. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0164hoKCjqGFeFQcPB66ThLn
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.
Follow-up to the ENOTEMPTY flake fixed in
completeRunArtifacts(merged in the previous PR). The same race was latent everywhere a test builds a real git repo in a temp dir.The race
git commit— andreceive-packon the far side of a push — spawns a detachedgit maintenance run --auto --quiet. Confirmed underGIT_TRACEon git 2.41:That process can still be writing into
.gitwhen a test's teardown removes the tree. Node's recursive removal does not retry by default, so one entry appearing after its parent was enumerated fails the whole call withENOTEMPTY. It is timing-dependent, which is why it surfaces on CI rather than locally.The change
New
tests/helpers/tempGit.tsholds both halves of the fix:disableGitAutoMaintenance(repoDir)— setsmaintenance.auto falseandgc.auto 0, so no background process outlives the test.removeTempDir(dir)— recursive removal with retries, covering any writer the config cannot reach (a clone made insidesrc/, say).Applied to the nine fixtures that create git objects, plus
tests/e2e/helpers/tempEnv.ts, which commits and so carried the race for every e2e test. Every repo each one builds is covered: working repos, bare remotes, and mid-test clones.Deliberately not swept
Six files run
git initand never commit —loadConfig,upgradeConfigSchema,initProject,cli/schemaUpgrade,repoRootedCli,loadConfigLayers.initcreates no objects, so nothing spawns maintenance and there is no writer to race. Touching them would be churn, not a fix.Verification
pnpm check:fullgreen.maintenance.auto=false/gc.auto=0, so the suppression actually lands.One caveat worth stating: I could not observe the spawn disappear inside vitest —
GIT_TRACEdoes not survive the worker env, so a control run with the helper call removed showed zero spawns too. The mechanism is confirmed by a standalone probe and the config is confirmed to apply, but that specific in-runner observation is missing.🤖 Generated with Claude Code
https://claude.ai/code/session_0164hoKCjqGFeFQcPB66ThLn