Fix WebSocket connection counter leak and guard mid-retry re-resolves#44
Merged
Merged
Conversation
- 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
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to c9be162 (orchestrator performance work):
active_ws_connectionsleaking on failed connection attempts. Thecounter is incremented on entry to
_ws_proxy_handlerbut was onlydecremented in the
finallyaround 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.
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).
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.