Repository navigation
fix: race in RunWithPrompts truncates output on process exit - #64
Merged
Merged
Conversation
…ompts Wait() closes the stdout pipe as soon as the child exits, racing our own Read on the same fd and occasionally truncating the last chunk of output. Fixes flaky examples/06_prompts.clitest under the new Go 1.27 CI matrix (golang:1.27-alpine), reproduced and verified fixed against that exact image. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
test-ash (1.27)in CI (run 35203905985) fails intermittently atmake examplesonexamples/06_prompts.clitest, missing the script's final "Created user: ..." lineRunWithPrompts(internal/runner/prompts.go) calledcmd.Wait()in a goroutine concurrently with the goroutine readingcmd.StdoutPipe()— a documented anti-pattern (Cmd.Waitcloses the pipe as soon as the child exits, which can race a concurrentReadon the same fd and truncate the last chunk). No application code changed since May; the newgolang:1.27-alpineCI matrix job just shifted timing enough to expose it<-readDone), then callcmd.Wait()once, sequentially, to reap the exit code — timeout now only kills the process, it no longer racesWaitTest plan
go test ./internal/runner/... -run TestRunWithPrompts -race -count=50— passmake test && make e2e && make exampleslocally — passexamples/06_prompts.clitest— 0 failuresmake test && make e2e && make examples) insidegolang:1.27-alpinevia podman, including a 30x stress loop — pass