Skip to content

fix: end Pipeline.stream iteration when aclose cancels the pipeline before it starts - #13702

Open
prassu017 wants to merge 1 commit into
deepset-ai:mainfrom
prassu017:fix/13700-stream-aclose-before-start
Open

prassu017 wants to merge 1 commit into
deepset-ai:mainfrom
prassu017:fix/13700-stream-aclose-before-start

Conversation

@prassu017

Copy link
Copy Markdown

Related Issues

Proposed Changes:

Pipeline.stream() sent the end-of-stream marker from a finally inside the pipeline task. When aclose() cancels that task before its first step, the finally never runs, so a consumer of the handle waits forever. The marker is now sent from a done callback on the task, which fires on every completion, including cancellation before start; the consumer then gets the cancellation.

How did you test it?

  • New test_aclose_before_pipeline_starts_ends_iteration: fails on main bbe4efe (TimeoutError), passes with the fix.
  • The reproduction script from the issue: Reader still waiting after close: True on main, False after.
  • test/core/pipeline/test_async_pipeline_stream.py, test_async_pipeline.py, test_pipeline.py: 72 passed.
  • ruff check, ruff format --check and mypy on the changed files: clean. Full suite and hatch run test:types not run.

Notes for the reviewer

The marker now arrives one loop iteration after the task finishes instead of just before; consumers already await the finished task on it, so ordering of chunks is unchanged.

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have added a unit test.
  • I've used a conventional commit type for the PR title (fix:).
  • I have added a release note file.
  • Ran ruff and mypy on the changed files (not the full pre-commit run).

AI-assisted; tests run locally.

…efore it starts

The end-of-stream marker was sent from a `finally` inside the pipeline task, which never runs when the task is
cancelled before its first step, so a consumer of the handle waited forever. Send it from a done callback instead.

Fixes deepset-ai#13700
@prassu017
prassu017 requested a review from a team as a code owner November 11, 2026 17:52
@prassu017
prassu017 requested review from bogdankostic and removed request for a team November 11, 2026 17:52
@vercel

vercel Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

@prassu017 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Nov 11, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @prassu017, thanks a lot for your contribution! 🙏

We noticed that the Contributor License Agreement (CLA) check (license/cla) hasn't passed yet, so we've temporarily moved this PR to draft and paused the review assignment.

To get your PR reviewed, please sign the CLA via the link in the license/cla check below (or in the CLA bot comment). As soon as the check turns green, this PR will automatically be marked ready for review again and a reviewer will be re-assigned.

@HaystackBot
HaystackBot removed the request for review from bogdankostic November 11, 2026 19:21
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Nov 11, 2026
@HaystackBot
HaystackBot marked this pull request as draft November 11, 2026 19:21
@github-actions github-actions Bot added the P2 Medium priority, add to the next sprint if no P1 available label Nov 12, 2026
@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @prassu017, just a friendly reminder: this PR is still in draft because the Contributor License Agreement (CLA) hasn't been signed yet. We'd love to review your contribution! Please sign the CLA via the link in the license/cla check, and this PR will automatically be marked ready for review.

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @prassu017, this PR is still waiting for the Contributor License Agreement (CLA) to be signed. Please note that if the CLA isn't signed within the next 24 hours, this PR will be automatically closed. Signing only takes a minute via the link in the license/cla check, and the PR will then automatically be marked ready for review.

@HaystackBot
HaystackBot marked this pull request as ready for review November 19, 2026 21:20
@HaystackBot HaystackBot removed the cla-pending PR is in draft until the contributor signs the CLA label Nov 19, 2026
@HaystackBot

Copy link
Copy Markdown
Contributor

Thanks for signing the CLA, @prassu017! 🎉 This PR is now ready for review again and the reviewer has been re-assigned.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Medium priority, add to the next sprint if no P1 available topic:core topic:tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pipeline stream reader hangs when the handle closes before the producer starts

3 participants