mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 02:48:13 -05:00
[PR #20049] [MERGED] fix: prevent ExternalReranker from blocking event loop during RAG queries #48492
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/20049
Author: @Classic298
Created: 12/19/2025
Status: ✅ Merged
Merged: 12/20/2025
Merged by: @tjbck
Base:
dev← Head:rerank📝 Commits (2)
4bb9ae8fix: prevent ExternalReranker from blocking event loop during RAG queries (#120)cc3793fMerge pull request open-webui#19030 from open-webui/dev (#122)📊 Changes
5 files changed (+27 additions, -1 deletions)
View changed files
📝
backend/open_webui/config.py(+6 -0)📝
backend/open_webui/main.py(+3 -0)📝
backend/open_webui/retrieval/models/external.py(+3 -0)📝
backend/open_webui/retrieval/utils.py(+1 -1)📝
backend/open_webui/routers/retrieval.py(+14 -0)📄 Description
devbranch. Not targeting thedevbranch will lead to immediate closure of the PR.Changelog Entry
Description
Fixes #19900
Fixes #19900 - ExternalReranker's synchronous HTTP requests were blocking the Python event loop, causing the entire Open WebUI application to freeze for 9-36+ seconds during reranking operations. This prevented all users from accessing the application while external reranker API calls were in progress.
This fix wraps the blocking reranking call in asyncio.to_thread() to offload it to a thread pool, and adds a configurable timeout to prevent indefinite hangs.
Additional Information
Issue Reference: Fixes #19900
Pattern Consistency: This fix follows the exact pattern used in commit
902c6cfb("perf: 50x performance improvement for external embeddings") which used asyncio.to_thread() for sentence transformers embeddingsCall Chain Verification: Confirmed entire call chain from FastAPI endpoint → chat_completion_files_handler() → get_sources_from_items() → query_doc_with_hybrid_search() → compression_retriever.ainvoke() → acompress_documents() is already async
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.