[PR #44] [MERGED] Fix WebSocket connection counter leak and guard mid-retry re-resolves #60

Closed
opened 2026-10-18 21:13:52 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/terminals/pull/44
Author: @Classic298
Created: 7/15/2026
Status: ✅ Merged
Merged: 7/19/2026
Merged by: @tjbck

Base: main ← Head: perf-followup-fixes


📝 Commits (1)

  • 82513c3 Fix WebSocket connection counter leak and guard mid-retry re-resolves

📊 Changes

2 files changed (+56 additions, -16 deletions)

View changed files

📝 README.md (+4 -0)
📝 terminals/routers/proxy.py (+52 -16)

📄 Description

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.

Contributor License Agreement

Note

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/terminals/pull/44 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 7/15/2026 **Status:** ✅ Merged **Merged:** 7/19/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `main` ← **Head:** `perf-followup-fixes` --- ### 📝 Commits (1) - [`82513c3`](https://github.com/open-webui/terminals/commit/82513c3eaa2d5799c04a8ecdd46c010aa09d25be) Fix WebSocket connection counter leak and guard mid-retry re-resolves ### 📊 Changes **2 files changed** (+56 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+4 -0) 📝 `terminals/routers/proxy.py` (+52 -16) </details> ### 📄 Description ## 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 <!-- link the performance issue here --> ## Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA. --> - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](./CLA.md), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-18 21:13:52 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/terminals#60
No description provided.