$ the-wire · showcase
Pure ASGI middleware restores streaming, socket reconnect fix lands
By RepoJournal · Filed · About Open WebUI
Open WebUI converted its last BaseHTTPMiddleware to pure ASGI, fixing a class of streaming and Content-Length bugs, and patched a socket reconnect gap for home-page chats.
Open WebUI's SecurityHeadersMiddleware is now pure ASGI, the last middleware still subclassing BaseHTTPMiddleware after CommitSession, AuthToken, WebsocketUpgradeGuard, and Redirect were moved earlier [1]. BaseHTTPMiddleware re-buffers response bodies through an anyio task group, which has known issues with streaming and Content-Length-bearing responses such as the FileResponse from /api/v1/audio/speech. The reimplementation stamps the configured headers directly on the ASGI response, so those responses no longer get buffered or corrupted.
A separate fix addresses socket reconnect recovery for chats started from the home page [2]. When a chat starts there, the URL switches to /c/{id} via history.replaceState, so the Chat component never remounts and chatIdProp stays empty; both websocket recovery paths, handleSocketConnect and chat:active fallback, were gated on chatIdProp and never ran. After any websocket drop during a response, such as mobile backgrounding, these chats now recover as intended. The change is related to polling, but the exact mechanism is not described.
Tool result embeds also got a fix restoring prompt confirmation [3]. FullHeightIframe renders them as srcdoc iframes without allow-same-origin, so their postMessage events carry the opaque origin "null". The trust gate in Chat.svelte only accepted same-origin sources or the global iframeSandboxAllowSameOrigin opt-in, so input:prompt, input:prompt:submit, and action:submit from Open WebUI's own embeds were silently dropped before reaching the confirm dialog. The dialog now fires again for these cross-origin embeds.
Japanese translation updates also landed, but contain no functional changes [4].
Action items
- → Update Open WebUI to a build containing the pure-ASGI SecurityHeadersMiddleware before relying on streaming or Content-Length responses from /api/v1/audio/speech open-webui/open-webui [immediate]
- → Verify socket reconnect recovery for chats started from the home page after deploying the fix open-webui/open-webui [plan]
References
- [1] fix: convert SecurityHeadersMiddleware to pure ASGI (#26924) ↗ open-webui/open-webui
- [2] fix: socket reconnect recovery never runs for chats started from the home page (#26913) ↗ open-webui/open-webui
- [3] fix: restore prompt confirmation for sandboxed tool result embeds ↗ open-webui/open-webui
- [4] i18n: Update Japanese language translations ↗ open-webui/open-webui