Repository navigation
fix(agent): retrieve failed prefetch when closing an event stream - #46513
Merged
BeautyyuYanli merged 1 commit intoNov 17, 2026
Merged
Conversation
BeautyyuYanli
approved these changes
Nov 17, 2026
BeautyyuYanli
left a comment
Contributor
There was a problem hiding this comment.
(This message is automated while I'm responsible for it.)
Verified the coalesce_agent_stream_events teardown fix and regression test against #46512: completed non-cancelled read-ahead exceptions are retrieved cleanly on early aclose() without affecting pending read-ahead cancellation or normal anext() error propagation. No additional changes were needed.
1 task done
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 #46512
Summary
When a Dify Agent event stream is closed, retrieve any exception from its finished read-ahead task. Pending reads still follow the existing cancel-and-await path. A consumer that keeps reading still receives source errors, including after a buffered text flush.
Verification
At
7688f7c9b1b4, the new test reproduces the event-loop warningTask exception was never retrieved. With the fix, the same test closes quietly.uv run --no-sync pytest -q tests/local/dify_agent/runtime/test_event_coalescer.py tests/local/dify_agent/runtime/test_runner.pypassed all 31 tests with the locked server dependencies. No external service was used.Ruff format and lint passed for both changed files. Targeted Pyrefly reported 0 errors.
Checklist
From Codex