Skip to content

fix(coding/execution): drain the pipes before reporting the capture - #37

Merged
rsbin1178 merged 1 commit into
mainfrom
fix/execution-drain-before-close
Oct 8, 2026
Merged

rsbin1178 merged 1 commit into
mainfrom
fix/execution-drain-before-close

Conversation

@rsbin1178

Copy link
Copy Markdown
Owner

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 finishIO with the trigger already fired and the readers still running, then writes to the process end after it returns: the previous implementation reports write |1: broken pipe (the read end was cut), and this one writes cleanly. It passes twenty -race repetitions.

The fixture that failed on CI (CaptureBytes = 10, ChunkBytes = 1, a 2ms sink) is the integration guard: it asserts the head holds abcde, the tail vwxyz and TotalBytes is 26 while the queue drops chunks.

TERM=xterm-256color go test ./... (89 packages), go test -race -count=20 ./internal/coding/execution/ and golangci-lint run --new-from-rev=HEAD~ ./... (0 issues) are clean.

Based on #36, which must merge first.

@rsbin1178
rsbin1178 changed the base branch from fix/acp-cancel-delivery to main October 8, 2026 14:56
@rsbin1178
rsbin1178 marked this pull request as ready for review October 8, 2026 14:56
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
rsbin1178 force-pushed the fix/execution-drain-before-close branch from d780630 to a1de623 Compare October 8, 2026 14:56
@rsbin1178
rsbin1178 merged commit 8b383a7 into main Oct 8, 2026
8 checks passed
@rsbin1178
rsbin1178 deleted the fix/execution-drain-before-close branch October 8, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant