From 6b843a8e8ecd0777bc9d0bebe90d2a2460285df5 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Fri, 3 Apr 2026 14:33:45 +0000 Subject: [PATCH] Use asyncio.to_thread for blocking manifest fetch in async endpoint The /api/update-check endpoint is async but fetch_and_cache_update_status performs a blocking HTTP request via urllib. Wrap it in asyncio.to_thread to avoid blocking the FastAPI event loop when the background thread has not yet completed the initial fetch. --- studio/backend/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/studio/backend/main.py b/studio/backend/main.py index 8942ffd74f..c0fbbdab95 100644 --- a/studio/backend/main.py +++ b/studio/backend/main.py @@ -230,7 +230,10 @@ async def update_check(): s = get_update_status() if not s.manifest_fetched: # Background thread may not have finished yet -- fetch inline. - s = fetch_and_cache_update_status() + # Run in a thread to avoid blocking the async event loop. + import asyncio + + s = await asyncio.to_thread(fetch_and_cache_update_status) return { "critical": s.critical, "announcement_badge": s.announcement_badge,