Repository navigation
fix: synchronize canceled input cleanup - #1876
Open
johnnychen94 wants to merge 2 commits into
Open
johnnychen94 wants to merge 2 commits into
johnnychen94 wants to merge 2 commits into
Conversation
Wait for cancelable input on killed shutdowns as well as normal exits. Retain the existing shutdown timeout, but defer reader Close until its captured input loop finishes if that timeout expires. Cover completion ordering, timeout ownership, fallback inputs, repeated shutdown, and cancellation through the public Program API. AI-assisted-by: Codex (GPT 6.1 sol)
AI-assisted-by: Codex (GPT 6.1 sol)
1 task done
johnnychen94
marked this pull request as ready for review
October 19, 2026 15:01
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.
Fixes #1875.
Wait for cancelable input on killed shutdowns as well as normal exits before closing the cancel reader. Context cancellation currently takes the killed path and can close the reader while its worker still accesses the cancellation pipe.
Preserve the existing 500ms shutdown bound. If the input loop is still active at that deadline, retain the original reader and completion channel and close that reader only after completion. The
Cancel() == falsefallback remains unchanged; this does not make arbitrary blocking readers cancelable or promise that delayed cleanup has finished whenRunreturns.Regression coverage
The added suite fails on the unmodified base and covers:
Validation
Passed locally on macOS arm64, Go 1.26.1:
The standalone terminal MWE in #1875 completed 100 cancellations under
-racewith this Bubble Tea change and the existing released Ultraviolet dependency. Examples also built with Go 1.26.7, as required by their module. Other platforms and GitHub CI have not yet been verified.Related work
Ultraviolet #221 separately makes pending event delivery cancelable. Without that fix, an exiting consumer may keep an input loop blocked; this PR retains the timeout and safe deferred cleanup for that case. No fork dependency or dependency upgrade is included here.
Prepared with Codex (GPT 6.1 sol). The reproduction, regression suites, and validation commands above were run locally.