fix(signal): close httpx client on health check failure to prevent connection leak - #3881
Closed
binhnt92 wants to merge 1 commit into
Closed
fix(signal): close httpx client on health check failure to prevent connection leak#3881binhnt92 wants to merge 1 commit into
binhnt92 wants to merge 1 commit into
Conversation
…nnection leak When connect() creates an httpx.AsyncClient and the subsequent health check fails (non-200 or network error), both return-False paths exit without closing the client. The TCP connection pool, SSL context, and file descriptors are leaked. On repeated reconnect attempts this accumulates. Close the client and set it to None on both failure paths.
Contributor
|
I'm working on Signal resource management in #3692 (FIFO eviction for sent-timestamp tracking). The httpx client teardown here looks solid — just want to note that if the health check fires while a message is being sent and tracked in |
Contributor
Author
|
Looks superseded by #5519 now. Ok to close this one. |
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.
When
connect()creates anhttpx.AsyncClientand the subsequent health check fails — either a non-200 response or a network error — bothreturn Falsepaths exit without closing the client. The TCP connection pool, SSL context, and file descriptors are leaked. On repeated reconnect attempts (e.g. the gateway retrying after a daemon restart), this accumulates open connections that are never cleaned up.Changes Made
Added
await self.client.aclose()andself.client = Noneon both failure paths in the health check block (gateway/platforms/signal.py).How to Test
4 tests: client closed on non-200, client closed on connection error, client kept on success, source verification.
Checklist