Skip to content

fix(dio): release response streams when consumers cancel - #2617

Draft
kaluli123123 wants to merge 1 commit into
cfug:mainfrom
kaluli123123:fix/response-stream-cancellation
Draft

kaluli123123 wants to merge 1 commit into
cfug:mainfrom
kaluli123123:fix/response-stream-cancellation

Conversation

@kaluli123123

@kaluli123123 kaluli123123 commented Oct 4, 2026 •

Copy link
Copy Markdown

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 a later CancelToken do not close the adapter response again.

Closes #2618.

The formal Bug report was created using the repository's actual template name (🐞 Bug Report) through GraphQL CreateIssueInput.issueTemplate. Its s: bug and h: need triage labels were retained at creation; it remains open and unlocked, and the issue-access workflow was skipped as intended. Earlier reports #2615 and #2616 remain closed and locked as template-admission history. This does not assert maintainer acceptance of the defect; normal triage and review remain pending.

Added six regressions through the public Dio API, covering .first, direct and paused cancellation, asynchronous cleanup, and late tokens after normal completion/error. The original four cancellation regressions fail without the fix; the response suite now passes 16 tests on VM and Chrome. Full Chrome checks passed 238 tests with 1 skip, Wasm checks passed 240 with 1 skip, and the native adapter's Flutter test runner passed 29. All ten packages passed analysis and formatting. Independent read-only review found no blocking issues.

Unverified/environment limits: Full VM checks report 382 passed, 10 skipped and 5 failed; the same five invalid-domain/DNS-network failures were reproduced on an independent unchanged-main worktree. They occur before this response-stream handler. Firefox, minimum-SDK testing, Android/iOS device integration, and upstream CI have not been verified. No failing expectations were changed and no lints or tests were disabled.

@cfug/dio-core This changes cancellation/timeout resource cleanup, so it merits the additional scrutiny described in the agent guidelines. Public APIs, adapters' signatures, and exception types are unchanged.

Implementation, regression tests and independent read-only review used Codex; the commit includes Co-authored-by: Codex <noreply@openai.com>. The GitHub-verified signed delivery tree is identical to locally tested ae533cc1f8. This draft remains pending the contributor's review and maintainer acceptance.

New Pull Request Checklist

  • I have read the Documentation.
  • I have read the Agent Contribution Guidelines.
  • I have searched for a similar pull request and found none addressing consumer-subscription cancellation.
  • I have based this branch on the verified latest main.
  • I have added effective regression tests.
  • I have updated documentation. (Not applicable: restores stream-cancellation behavior without a new API.)
  • I have run the tests without failures. (The five unchanged-main VM network failures are disclosed above.)
  • I have updated dio/CHANGELOG.md under Unreleased.

Propagate consumer cancellation to the source response subscription, stop receive-timeout work, and wait for asynchronous source cleanup. Keep normal completion and late CancelToken cleanup idempotent.

Closes cfug#2616

Co-authored-by: Codex <noreply@openai.com>
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.

Cancelling a response stream subscription leaves the adapter response subscribed

1 participant