From 654e958ad5281470c65356d54d69d567b33a89d9 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 15 Apr 2026 07:59:28 +0000 Subject: [PATCH] fix(stream): reject non-positive timeout env values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _float_env now falls back to default when parsed value is <= 0. asyncio.wait_for with a 0 or negative timeout would fail immediately every call, silently disabling the resume log — misconfiguration now degrades to default behavior with a warning instead. --- backend/open_webui/socket/main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/socket/main.py b/backend/open_webui/socket/main.py index 90414093b1..99579fa9ab 100644 --- a/backend/open_webui/socket/main.py +++ b/backend/open_webui/socket/main.py @@ -185,15 +185,21 @@ RESUME_STREAM_TTL_REFRESH_EVERY = 64 # Replay read timeout: looser since a resume is user-blocking anyway # and silent timeout here is worse than a brief extra wait. Both # configurable for infra where Redis isn't colocated. -def _float_env(name: str, default: float) -> float: +def _float_env(name: str, default: float, minimum: float = 0.0) -> float: val = os.environ.get(name) if val is None or val == '': return default try: - return float(val) + parsed = float(val) except (TypeError, ValueError): log.warning(f'Invalid {name}={val!r}; using default {default}') return default + if parsed <= minimum: + log.warning( + f'{name}={parsed} is not positive (must be > {minimum}); using default {default}' + ) + return default + return parsed RESUME_STREAM_REDIS_TIMEOUT_SEC = _float_env('RESUME_STREAM_REDIS_TIMEOUT_SEC', 0.1)