fix(webui): keep version checks on the gateway event loop (#6376)
* fix(webui): keep version checks on the gateway event loop * fix(webui): keep update channel failures factual Note: CI failed, but it’s not related to this PR.
This commit is contained in:
1 parent
29d1600837
commit
4dc695ca76
15 files changed
+118
-51
No files matched your search
@@ -9,7 +9,7 @@ import platform
|
||||
import re
|
||||
import subprocess
|
||||
import time
|
||||
from collections.abc import Callable, Iterable, Mapping
|
||||
from collections.abc import Awaitable, Callable, Iterable, Mapping
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any, TypedDict, cast
|
||||
@@ -86,7 +86,7 @@ class SystemSettingsOperations:
|
||||
mcp_presets_action: SettingsOperation
|
||||
reload_mcp: SettingsOperation
|
||||
mcp_runtime_status: Callable[[], Mapping[str, str]] | None
|
||||
check_for_update: SettingsOperation
|
||||
check_for_update: Callable[[], Awaitable[dict[str, Any]]]
|
||||
channel_feature_action: SettingsOperation | None = None
|
||||
channel_runtime_status: Callable[[], dict[str, Any]] | None = None
|
||||
|
||||
@@ -1225,7 +1225,7 @@ class SystemSettingsHandler:
|
||||
operations: SystemSettingsOperations,
|
||||
) -> SettingsRouteResult:
|
||||
try:
|
||||
update_info = await asyncio.to_thread(operations.check_for_update)
|
||||
update_info = await operations.check_for_update()
|
||||
except Exception as exc:
|
||||
self.logger.warning("version check failed ({})", type(exc).__name__)
|
||||
return SettingsRouteResult.failure(500, "version check failed")
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
@@ -14,7 +13,12 @@ from nanobot.release_feed import ReleaseFeed, ReleaseFeedError
|
||||
from nanobot.update_channel import read_update_channel
|
||||
|
||||
|
||||
async def _check() -> dict[str, Any]:
|
||||
async def check_for_update() -> dict[str, Any]:
|
||||
"""Check fresh release data on the caller's event loop without installing.
|
||||
|
||||
The feed shares the gateway's pinned-DNS transport lock. Keep discovery on
|
||||
that loop rather than creating a temporary event loop in a worker thread.
|
||||
"""
|
||||
selection = read_update_channel()
|
||||
current = nanobot.__version__
|
||||
status: dict[str, Any] = {
|
||||
@@ -46,12 +50,3 @@ async def _check() -> dict[str, Any]:
|
||||
if read_update_channel() != selection:
|
||||
raise ValueError("Update channel changed while checking; check again")
|
||||
return result
|
||||
|
||||
|
||||
def check_for_update() -> dict[str, Any]:
|
||||
"""Blocking settings adapter. Every check is fresh and never installs.
|
||||
|
||||
The feed's ETag cache guards generations, not availability. Older clients
|
||||
still read updateAvailable; channel status is additive.
|
||||
"""
|
||||
return asyncio.run(_check())
|
||||
Reference in new issue
Block a user