Repository navigation
test: tolerate a process already gone when cleaning up the git timeout test - #334
Merged
Merged
Conversation
This was referenced Oct 27, 2026
Merged
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.
Context
configfile runs
gitfor almost everything, so before working it callsensureGit(insrc/process.ts), which runsgit --versionwith a timeout. On timeout it kills git's whole process group, and it must not hang on an output pipe that a child of git still holds open.tests/git.test.tscovers that with a fakegitscript: it startsperl -e 'use POSIX; setsid(); sleep 20' &(a child that leaves git's process group, so the group kill misses it), writes perl's pid to a file, then sleeps. The test expectedensureGitto give up after 0.3 s, and itsfinallyblock kills the escaped perl so nothing is left running.Why
The develop build after #332 failed on this test (run 40461286040, ubuntu, Node 26) with
kill ESRCHattests/git.test.ts:178: the assertions passed, the cleanup threw.On a slow runner the 300 ms timeout can fire before perl has run
setsid(). Perl is then still in git's group, the group kill takes it down, and the cleanup'sprocess.kill(pid, 'SIGKILL')targets a process that no longer exists. The same commit passed on its pull request, and the next develop build passed: it is a timing race, not a regression. The test dates from #289.That race also hid a weaker test: when perl does not leave the group in time, nothing holds git's output open, and the test only checks again what "stops waiting for a git that does not answer" already checks. On a fast Mac, perl needs 150 to 200 ms to leave the group, so 300 ms left little margin.
Change
Two commits, both in that one test:
tests/e2e.test.tsalready uses for its process groups. Rethrowing anything other thanESRCHwas not an option: Biome rejects athrowinsidefinally, and an error thrown by the cleanup would hide the test's own failure.setsid(). If the marker is missing when the timeout fires, the test is skipped with a note instead of passing.Test-only change: no behaviour, documentation or compatibility impact. The test takes about 1.2 s longer.
Review order
tests/git.test.ts, the test "stops waiting on time even when something git started keeps its output open": the fake git script, then the assertions and the skip, then thefinallyblock.Tests
pnpm typecheckandpnpm lintare clean.pnpm vitest run: 810 tests pass. The test passed 10 times in a row, and no perl process was left afterwards.ensureGitchanged to wait for the output to close after the timeout (thefinishcall removed from the timer), the test fails ("Test timed out in 5000ms"). The change was reverted.setsid(), the test is skipped instead of passing. The change was reverted.