Skip to content

fix: close every retriever in MultiRetriever even when one raises - #13844

Draft
DZH166 wants to merge 1 commit into
deepset-ai:mainfrom
DZH166:fix/multi-retriever-close-isolation
Draft

DZH166 wants to merge 1 commit into
deepset-ai:mainfrom
DZH166:fix/multi-retriever-close-isolation

Conversation

@DZH166

@DZH166 DZH166 commented Nov 20, 2026

Copy link
Copy Markdown

Problem

MultiRetriever.close() and close_async() run the cleanup of every owned retriever in a bare loop with no per-retriever isolation, so the first retriever whose close() raises (already-closed client, dropped connection, close timeout) aborts the loop and every later retriever is never closed - their resources leak while only the unrelated first error surfaces. close_async() has the same flaw on both its native path and its synchronous fallback.

before: close()/close_async() skip the healthy retriever after the first error
after : every retriever is closed; the first error is re-raised afterwards

Fix

Wrap each close in try/except BaseException, remember the first failure, finish closing the rest, then re-raise.

Tests

test/components/retrievers/test_multi_retriever.py (3 new tests: close, close_async, async sync-fallback):

pytest test/components/retrievers/test_multi_retriever.py -q    # before: 3 failed, 60 passed, 6 skipped   after: 63 passed, 6 skipped

@DZH166
DZH166 requested a review from a team as a code owner November 20, 2026 16:55
@DZH166
DZH166 requested review from davidsbatista and removed request for a team November 20, 2026 16:55
@vercel

vercel Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @DZH166, 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.

Please note that PRs without a signed CLA are automatically closed 48 hours after they were opened.

@HaystackBot
HaystackBot removed the request for review from davidsbatista November 20, 2026 18:25
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Nov 20, 2026
@HaystackBot
HaystackBot marked this pull request as draft November 20, 2026 18:25

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

cla-pending PR is in draft until the contributor signs the CLA topic:tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants