Repository navigation
fix: close client on authenticate() failure to prevent socket/task leak in ClientPool - #279
Merged
Merged
Conversation
…ak in ClientPool ClientPool.new() left partially-initialized clients unclosed and untracked whenever authenticate() raised after start() had already opened the connection (e.g. an OAuth2 timeout), leaking a socket and listener task on every failure. Connection.close() is also made a safe no-op when the socket never finished opening, so close() can't itself raise if start() fails before authenticate() is reached. Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Only a non-blocking test-coverage nit remains.
Review effort: Lite
Findings: None
What changed in this PR
Fixes leaked sockets and listener tasks when client startup or authentication fails.
Changes:
- Cleans up partially initialized clients on failure.
- Makes
Connection.close()safe before socket creation. - Adds authentication-failure regression coverage.
| File | Summary |
|---|---|
tests/test_client.py |
Tests cleanup after authentication failure. |
rstream/connection.py |
Safely handles unopened connections. |
rstream/client.py |
Cleans up failed client initialization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Fixes: #278
ClientPool.new() left partially-initialized clients unclosed and untracked whenever authenticate() raised after start() had already opened the connection (e.g. an OAuth2 timeout), leaking a socket and listener task on every failure. Connection.close() is also made a safe no-op when the socket never finished opening, so close() can't itself raise if start() fails before authenticate() is reached.