Skip to content

feat(realtime)!: rename RealtimeClient.close() to aclose() - #2036

Merged
spydon merged 2 commits into
mainfrom
lukasklingsbo/sdk-2977-realtime-rename-realtimeclientclose
Nov 11, 2026
Merged

spydon merged 2 commits into
mainfrom
lukasklingsbo/sdk-2977-realtime-rename-realtimeclientclose

Conversation

@spydon

@spydon spydon commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Resolves SDK-2977.

What

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.

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Explain Change →

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • 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.

@spydon
spydon merged commit 6eca35f into main Nov 11, 2026
26 checks passed
@spydon
spydon deleted the lukasklingsbo/sdk-2977-realtime-rename-realtimeclientclose branch November 11, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant