From 3d459470532ba01b4d3609da641f27a189069cb2 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Fri, 24 Jul 2026 01:09:23 +0200 Subject: [PATCH] fix: report sub-second timings in the X-Process-Time header (#27368) The header value was truncated with int(), so every request faster than one second reported X-Process-Time: 0 and the header carried no information for exactly the requests it is meant to describe. Emit fractional seconds with microsecond precision instead, matching the pre-ASGI-refactor behavior where the raw float was sent. --- backend/open_webui/utils/asgi_middleware.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/utils/asgi_middleware.py b/backend/open_webui/utils/asgi_middleware.py index 2c3412df48..d28abc90f8 100644 --- a/backend/open_webui/utils/asgi_middleware.py +++ b/backend/open_webui/utils/asgi_middleware.py @@ -172,9 +172,9 @@ class AuthTokenMiddleware: async def send_with_timing(message: Message) -> None: if message['type'] == 'http.response.start': - process_time = int(time.monotonic() - start_time) + process_time = time.monotonic() - start_time headers = MutableHeaders(scope=message) - headers['X-Process-Time'] = str(process_time) + headers['X-Process-Time'] = f'{process_time:.6f}' await send(message) await self.app(scope, receive, send_with_timing)