mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 02:48:13 -05:00
[PR #21158] [MERGED] fix: prevent worker death during document upload by using run_coroutine_threadsafe #49002
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/21158
Author: @Classic298
Created: 2/4/2026
Status: ✅ Merged
Merged: 2/12/2026
Merged by: @tjbck
Base:
dev← Head:claude/fix-upload-process-issue-hcB7K📝 Commits (2)
ea38916fix: prevent worker death during document upload by using run_coroutine_threadsafe92f7f5cadd env var📊 Changes
2 files changed (+13 additions, -3 deletions)
View changed files
📝
backend/open_webui/main.py(+4 -0)📝
backend/open_webui/routers/retrieval.py(+9 -3)📄 Description
Best solution would be to fully propagate async/await the entire chain but this is a lot more work.
Replace asyncio.run() with asyncio.run_coroutine_threadsafe() in save_docs_to_vector_db() to prevent uvicorn worker health check failures.
The issue: asyncio.run() creates a new event loop and blocks the thread completely, preventing the worker from responding to health checks during long-running embedding operations (>5 seconds default timeout).
The fix: Schedule the async embedding work on the main event loop using run_coroutine_threadsafe(). This keeps the main loop responsive to health check pings while the sync caller waits for the result.
Changes:
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.