Repository navigation
fix(dio): release response streams when consumers cancel - #2624
Open
JiyadAhammad wants to merge 1 commit into
Open
JiyadAhammad wants to merge 1 commit into
JiyadAhammad wants to merge 1 commit into
Conversation
Consumer cancellation of a ResponseType.stream response now cancels the adapter-response subscription, stops receive-timeout work, and awaits asynchronous source cleanup. Normal completion and later CancelTokens do not trigger duplicate closures. Closes cfug#2618 Co-authored-by: Antigravity <antigravity@google.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.
Consumer cancellation of a
ResponseType.streamresponse now cancels the adapter-response subscription, stops receive-timeout work, and awaits asynchronous source cleanup. Normal completion and later CancelTokens do not trigger duplicate closures.Closes #2618
Motivation & Background
When a consumer stopped consuming a response stream early (e.g.
response.data!.stream.first,take(), or manual subscription cancellation),handleResponseStreamhad noonCancelhandler. As a result, the adapter socket remained connected and receiving bytes, the receive timer kept ticking, and lateCancelTokeninvocations threwStateError.Verification
Added 6 regression tests covering
.first, direct cancellation, paused cancellation, asynchronous cleanup, and late tokens after normal completion/error. All 16 tests indio/test/response/response_stream_test.dartpass on the Dart VM. Formatting anddart analyzeare clean.@cfug/dio-core This touches timeout/cancellation cleanup as called out in AGENTS.md §3. Public APIs and adapter signatures remain unchanged.
Implementation and tests developed with Antigravity assistance.
New Pull Request Checklist
mainbranch to avoid conflicts (via merge from master or rebase)CHANGELOG.mdin the corresponding packageAdditional context and info (if any)