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.
This commit is contained in:
Daniel Han 2026-04-03 14:33:45 +00:00
commit 6b843a8e8e

View file

@ -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,