fix(run): start pipe drain before waitForProcess to avoid 64KB deadlock#6
Merged
poolcamacho merged 1 commit intomasterfrom Apr 15, 2026
Merged
fix(run): start pipe drain before waitForProcess to avoid 64KB deadlock#6poolcamacho merged 1 commit intomasterfrom
poolcamacho merged 1 commit intomasterfrom
Conversation
Closes #4. Reported by @just-doit. Reproducible on any repo whose 'git log' output exceeds the macOS pipe buffer (~64 KB). Regression introduced when GitService.run was decomposed into helpers: the read tasks were moved inside drainAndClose, which the run method called only AFTER waitForProcess returned. While the process was alive nothing was reading the pipes, so once the kernel buffer filled git blocked on write, never exited, and the timeout fired. Split the helper into startDraining (synchronous, returns the task handles) and awaitDrain (async, awaits values and closes the read ends). The run method now starts the drain immediately after process.run() and awaits it after waitForProcess, restoring the behaviour that was lost in the decomposition.
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.
Closes #4.
Reported by @just-doit. Reproducible on any repo whose
git logoutput exceeds the macOS pipe buffer (~64 KB).Regression
When
GitService.runwas decomposed into helpers, the read tasks were moved insidedrainAndClose, whichruncalled only afterwaitForProcessreturned:While the process was alive, nothing was reading the pipes. Once the kernel pipe buffer filled (~64 KB), git blocked on write,
process.isRunningstayed true, and the timeout eventually fired.Fix
Split
drainAndCloseinto:startDraining(synchronous, returns the twoTaskhandles) — called right afterprocess.run().awaitDrain(async, awaits the values and closes the read ends) — called afterwaitForProcess.The detached read tasks now live for the whole lifetime of the child process, so the pipe buffer can't deadlock git regardless of output size.
Verification
xcodebuild buildcleanswiftlint --strictcleangit log --allexceeds 64 KB onb0a0a02, confirmed the timeout. Re-tested on this branch, loads in normal time with no timeout.