You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(realtime)!: rename RealtimeClient.close() to aclose() - #2036
RealtimeClient.close() is renamed to aclose(). close() is removed, not deprecated, since main is still in alpha.
Why
aclose() is the Python name for an async close, and the top-level AsyncClient already uses it since #2035. With the new name, contextlib.aclosing(realtime_client) works, the same as for async generators (PEP 525) and httpx.AsyncClient.
Changes
realtime/client.py: renames the method and updates the call in connect_once.__aexit__.
sdk-compliance.yaml: lists RealtimeClient.aclose under realtime.client.disconnect.
MIGRATION.md: adds a section on the rename.
tests/test_close.py: checks that aclose() and contextlib.aclosing close the websocket.
Breaking change
Code that calls await realtime_client.close() must call await realtime_client.aclose() instead. Code that uses async with connect_once(...) is unaffected.
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
API Changes
Realtime client connections are now closed asynchronously using aclose(). The former close() method has been removed.
Documentation
The migration guide explains the method rename and removal.
Tests
Added coverage to verify that closing a client, including when leaving a cleanup context, closes its WebSocket connection.
RealtimeClient.close() is renamed to RealtimeClient.aclose(). The connect_once exit handler now calls aclose(). New async tests check direct closure and closure after an aclosing context exits. The migration guide and SDK compliance registry identify the renamed method.
Possibly related PRs
supabase/supabase-py#2034: Adds RealtimeClient.close() and uses it to shut down the realtime client when AsyncClient exits.
Change: Feature
Merge Risk: Minimal · up to 0c1be
This is an intentional, documented breaking rename of an async close method in an alpha release. The internal caller and tests are updated, and the migration guide tells users how to adapt. No merge-blocking risk was found.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: fefb32d8-5b14-4f46-90b9-f6f88668a404
Commits
Reviewing files that changed from the base of the PR and between 1ab137d and 0c1be49.
Files selected for processing: 4
MIGRATION.md
sdk-compliance.yaml
src/realtime/src/realtime/client.py
src/realtime/tests/test_close.py
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
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
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.
Resolves SDK-2977.
What
RealtimeClient.close()is renamed toaclose().close()is removed, not deprecated, sincemainis still in alpha.Why
aclose()is the Python name for an async close, and the top-levelAsyncClientalready uses it since #2035. With the new name,contextlib.aclosing(realtime_client)works, the same as for async generators (PEP 525) andhttpx.AsyncClient.Changes
realtime/client.py: renames the method and updates the call inconnect_once.__aexit__.sdk-compliance.yaml: listsRealtimeClient.acloseunderrealtime.client.disconnect.MIGRATION.md: adds a section on the rename.tests/test_close.py: checks thataclose()andcontextlib.aclosingclose the websocket.Breaking change
Code that calls
await realtime_client.close()must callawait realtime_client.aclose()instead. Code that usesasync with connect_once(...)is unaffected.