open-webui/backend/open_webui
Classic298 02b65ea582
fix: don't hang terminal proxy when one forwarding pump exits first (#25479)
The proxy gathered _client_to_upstream and _upstream_to_client with
return_exceptions=True. When upstream sends a graceful CLOSE,
_upstream_to_client returns but gather keeps waiting on
_client_to_upstream, which is blocked in ws.receive() until the browser
disconnects. The handler stays pending and the finally: session.close()
cleanup is deferred, leaking a ClientSession and an open browser socket.

Use asyncio.wait(return_when=FIRST_COMPLETED) and cancel the pending
sibling, so the proxy unwinds as soon as either direction finishes. The
pumps' bare except Exception already lets CancelledError (a BaseException)
propagate, so cancellation is clean and they need no change.

Fixes #25464

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 10:10:04 -07:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal refac 2026-05-21 16:25:25 +04:00
migrations refac 2026-05-21 15:29:49 +04:00
models fix: use db instead of undefined session in chats model (#25455) 2026-06-01 09:25:35 -07:00
retrieval refac 2026-06-01 09:53:04 -07:00
routers fix: don't hang terminal proxy when one forwarding pump exits first (#25479) 2026-06-01 10:10:04 -07:00
socket Update main.py (#25271) 2026-05-31 14:48:51 -07:00
static refac 2026-05-12 03:04:35 +09:00
storage refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
tools fix: add knowledge_id access check in search_knowledge_files (BOLA) (#25113) 2026-05-28 16:23:49 -05:00
utils feat: cap profile image data URI size to bound model/avatar bloat (#25476) 2026-06-01 09:57:06 -07:00
__init__.py refac 2026-05-09 02:38:08 +09:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py refac 2026-05-31 15:10:48 -07:00
constants.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
env.py feat: cap profile image data URI size to bound model/avatar bloat (#25476) 2026-06-01 09:57:06 -07:00
functions.py fix: emit [DONE] for AsyncGenerator pipe returns (#24763) 2026-05-19 22:07:56 +04:00
main.py refac 2026-05-31 15:10:48 -07:00
tasks.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00