Skip to content

Fix WebSocket connection counter leak and guard mid-retry re-resolves#44

Merged
tjbck merged 1 commit into
open-webui:mainfrom
Classic298:perf-followup-fixes
Jul 19, 2026
Merged

Fix WebSocket connection counter leak and guard mid-retry re-resolves#44
tjbck merged 1 commit into
open-webui:mainfrom
Classic298:perf-followup-fixes

Conversation

@Classic298

Copy link
Copy Markdown
Contributor

Description

Follow-up to c9be162 (orchestrator performance work):

  • Fix active_ws_connections leaking on failed connection attempts. The
    counter is incremented on entry to _ws_proxy_handler but was only
    decremented in the finally around the relay loop, so every early return
    (instance resolve failure, connect-retry exhaustion) leaked a permanent +1 —
    the stats counter grows monotonically whenever containers are unreachable.
    The counter is now maintained by a try/finally around the whole handler body.
  • Guard the mid-retry instance re-resolutions added in c9be162: if
    provisioning fails during a retry, the exception escaped as an unhandled
    500 / raw ASGI error. Now returns the existing 502 (HTTP) or closes with
    4003 (WebSocket).
  • Document the new settings (TERMINALS_STATUS_CACHE_TTL,
    TERMINALS_TOKEN_CACHE_TTL, TERMINALS_WS_COMPRESSION,
    TERMINALS_ACCESS_LOG) in the README configuration table.

Related Issues

Contributor License Agreement

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.

- active_ws_connections was incremented on entry to _ws_proxy_handler
  but only decremented in the finally around the relay loop, so every
  early return (instance resolve failure, connect-retry exhaustion)
  leaked a permanent +1 and the stats counter grew monotonically under
  connect failures. Maintain the counter with a try/finally around the
  entire proxy body so every exit path decrements it.
- The instance re-resolution added to the HTTP and WebSocket retry
  loops was unguarded: if provisioning fails mid-retry, the exception
  escaped as an unhandled 500 / raw ASGI error. Return the existing
  502 responses (HTTP) or close 4003 (WebSocket) instead.
- Document the recently added TERMINALS_STATUS_CACHE_TTL,
  TERMINALS_TOKEN_CACHE_TTL, TERMINALS_WS_COMPRESSION, and
  TERMINALS_ACCESS_LOG settings in the README configuration table.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XvuMBS4XMccRrCwNxfoPsu
@tjbck

tjbck commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Thanks!

@tjbck
tjbck merged commit 109d844 into open-webui:main Jul 19, 2026
@Classic298
Classic298 deleted the perf-followup-fixes branch July 19, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants