Repository navigation
fix(coding/execution): drain the pipes before reporting the capture - #37
Merged
Merged
Conversation
finishIO closed the read ends on three of its four branches before the readers had necessarily drained, including the one an output trigger takes. Closing them makes a pending Read come back as os.ErrClosed, so the retained capture and the byte count described how fast the readers happened to be scheduled rather than what the process wrote: on CI the head of a twenty-six byte output held one byte where the test expects five. The trigger branch now drains the readers first and force-closes only when the drain grace expires, which is the bound the other branches already relied on. The output limit stays a truncation rather than a failure, and the process is still stopped by the trigger in waitForProcess. Measured: a new test drives finishIO directly with the trigger fired and the readers still running. It fails against the previous implementation with "write |1: broken pipe" and passes with this change, twenty -race repetitions each.
rsbin1178
force-pushed
the
fix/execution-drain-before-close
branch
from
October 8, 2026 14:56
d780630 to
a1de623
Compare
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.
finishIO closed the read ends on three of its four branches before the readers had
necessarily drained, including the one an output trigger takes. Closing them makes a
pending Read come back as os.ErrClosed, so the retained capture and the byte count
described how fast the readers happened to be scheduled rather than what the process
wrote: on CI the head of a twenty-six byte output held one byte where the test
expects five.
The trigger branch now drains the readers first and force-closes only when the drain
grace expires, which is the bound the other branches already relied on. The output
limit stays a truncation rather than a failure, and the process is still stopped by
the trigger in waitForProcess.
Measured: a new test drives finishIO directly with the trigger fired and the readers
still running. It fails against the previous implementation with
"write |1: broken pipe" and passes with this change, twenty -race repetitions each.
Evidence
The new test drives
finishIOwith the trigger already fired and the readers still running, then writes to the process end after it returns: the previous implementation reportswrite |1: broken pipe(the read end was cut), and this one writes cleanly. It passes twenty-racerepetitions.The fixture that failed on CI (
CaptureBytes = 10,ChunkBytes = 1, a 2ms sink) is the integration guard: it asserts the head holdsabcde, the tailvwxyzandTotalBytesis 26 while the queue drops chunks.TERM=xterm-256color go test ./...(89 packages),go test -race -count=20 ./internal/coding/execution/andgolangci-lint run --new-from-rev=HEAD~ ./...(0 issues) are clean.Based on #36, which must merge first.