fix: progressive ask can deadlock when the UI/output consumer exits early#793
Closed
sam-saffron-jarvis wants to merge 1 commit into
Closed
fix: progressive ask can deadlock when the UI/output consumer exits early#793sam-saffron-jarvis wants to merge 1 commit into
sam-saffron-jarvis wants to merge 1 commit into
Conversation
Owner
|
Closing; fix will be applied directly to main. |
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.
What changed
askProgressiveBridgecancellation-aware by adding a stop signal and routing all event delivery through a helper that stops blocking when the consumer has exited.cmd/ask.goto callbridge.Stop()before waiting on the run goroutine if JSON streaming or the renderer returns a write/render error.Why this is high-value
Progressive ask is one of the main streaming paths in
term-llm, including JSON output and rich rendering. Before this change, if the output consumer returned early (for example due to a broken pipe or renderer failure), the producer goroutine could keep sending into the bridge until the buffer filled and then block forever. The caller then waited on<-runCh, so the whole command could hang even though stdout/the renderer was already gone.This fix preserves normal behavior but makes the bridge shut down cleanly in the failure path, preventing a user-visible deadlock in automation and piped usage.
Validation
gofmt -w cmd/ask_progressive.go cmd/ask.go cmd/ask_progressive_test.gogo build ./...go test ./...TestAskProgressiveBridge_StopUnblocksProducerAfterConsumerWriteError