Skip to content

chore(realtime): remove unused _leave_open_topic - #1930

Merged
spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-2676-realtime-remove-unused-asyncrealtimeclient_leave_open_topic
Nov 3, 2026
Merged

spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-2676-realtime-remove-unused-asyncrealtimeclient_leave_open_topic

Conversation

@spydon

@spydon spydon commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Resolves SDK-2676.

What

Removes AsyncRealtimeClient._leave_open_topic(). Nothing called it, so coverage always reported it as uncovered. Also removes the AsyncMock stub for it in tests/test_presence.py.

Why delete instead of wiring it up

  • realtime-js never called it from channel(). In realtime-js v2 (and in phoenix.js, where it comes from), the only caller of _leaveOpenTopic was RealtimeChannel._rejoin(). channel() returned the existing channel for the topic. realtime-js removed it in feat(realtime): use phoenix's js lib inside realtime-js supabase-js#2119 when it switched to phoenix's JS client.
  • Python already removed that same caller on purpose. git log -S _leave_open_topic shows that cfbe594 (fix(realtime): ammend reconnect logic to not unsubscribe #1346, "ammend reconnect logic to not unsubscribe") replaced the call in _rejoin() with a log line. During a reconnect the helper found the rejoining channel itself and unsubscribed it. The method has been dead since then. Its only other appearance is the test stub added in 6be6c0c.
  • It can't find a duplicate. self.channels is a dict keyed by topic, so the helper could only ever match self.channels[topic], which is the channel being joined. When channel() replaces a leaving channel, the old instance is dropped from the dict and is already leaving, not joined or joining. _remove_channel() only deletes the entry if it is still the same instance, so the replacement is safe without this helper.

Testing

  • git grep leave_open returns nothing.
  • make ruff is clean.
  • With realtime infra running, uv run --frozen --package realtime pytest tests gives 116 passed, including test_channel_rejoin.py, test_subscription_status.py and test_presence.py.
  • uv run --frozen --package realtime mypy src/realtime tests reports no issues.

Review

I reviewed the diff with /code-review (high effort). It found no issues, so nothing changed.

@spydon
spydon requested a review from o-santi as a code owner November 3, 2026 13:05
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 22090f0 and de68d7b.

Files selected for processing: 2
  • src/realtime/src/realtime/_async/client.py
  • src/realtime/tests/test_presence.py
  • 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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@spydon
spydon merged commit ca09489 into main Nov 3, 2026
42 checks passed
@spydon
spydon deleted the lukasklingsbo/sdk-2676-realtime-remove-unused-asyncrealtimeclient_leave_open_topic branch November 3, 2026 13:10
spydon added a commit that referenced this pull request Nov 3, 2026
…pabase (#1931)

## What

Adds tests to the least-covered areas of supabase-py. No library code
changes.

Overall line coverage of library code (`--cov=src`, sync and async
trees, with local infra) goes from about 91.3% to 98.6%:

| Package   | Before | After |
| --------- | ------ | ----- |
| auth      | 89%    | 98%   |
| storage   | 91%    | 99%   |
| postgrest | 94%    | 99%   |
| realtime  | 92%    | 98%   |
| supabase  | 92%    | 98%   |
| functions | 99%    | 99%   |

## Tests added

All new tests mock HTTP with `httpx.MockTransport`, or mock the
websocket connection, so none of them need infra.

- `src/storage/tests/test_vectors.py`: every vector bucket, index and
vector operation (request paths, request bodies, omitted optional
fields, the `delete` batch size limit, API error parsing), plus
analytics bucket create, list and delete, and the missing-`pyiceberg`
error. Runs against both the sync and async clients.
- `src/auth/tests/_async/test_client_flows.py`: `initialize` from
implicit grant URLs (query and fragment, recovery, error redirects,
incomplete redirects), restoring and refreshing stored sessions, ID
token, SSO and OAuth sign-in (including PKCE), code exchange, identity
linking, reauthentication, MFA enroll, challenge, verify, unenroll and
list, the "requires a session" errors, API error mapping, and pagination
headers when listing OAuth clients.
- `src/auth/tests/_async/test_jwks_and_refresh.py`: `get_claims` with
real ES256 keys (JWKS caching and TTL, supplied JWKS, unknown key, empty
JWKS, forged signature), retry scheduling on network errors, and the
PKCE email change in `update_user`.
- `src/realtime/tests/test_client_channels.py` and
`test_channel_internals.py`: channel creation, replacement and removal,
`set_auth`, send buffering, presence state and diff handling, join reply
handling for postgres changes bindings, `join()`, the listen loop,
connect retries and backoff, and send and heartbeat close handling.
- `src/postgrest/tests/test_response_handling.py` and
`test_builder_edges.py`: error mapping for `select`, `single`,
`maybe_single` and `explain`, CSV and explain output, turning retries
off, retrying GET requests (writes aren't retried, and retries stop at
the limit), plus filter encodings (`fts` variants, `contained_by`, `ov`,
`contains`, `sl`), `match`, `offset`, `range`, `upsert` and the
deprecation warnings.
- `src/supabase/tests/_async/test_client.py`: falling back to the API
key when reading the session fails, and channel helper delegation.

The auth and supabase sync tests are generated with `make
<pkg>.build-sync`.

## Bugs found while writing these tests

Each was filed and fixed in its own PR. This branch first pinned them
with strict `xfail` tests, and those markers have been removed now that
every fix is on `main`.

- SDK-2667, #1919: `storage3.create_client()` always emitted the timeout
`DeprecationWarning`.
- SDK-2668, #1921: `MetadataConfiguration` rejected its Python field
name.
- SDK-2669, #1920: `set_session()` raised `IndexError` for an access
token that isn't a JWT.
- SDK-2670, #1923: implicit grant tokens in the URL fragment were
ignored.
- SDK-2671, #1922: `CodeExchangeParams` required `code_verifier`.
- SDK-1674, #1925: `remove_all_channels()` left the channels registered.
- SDK-2672, #1929: a join reply without matching `postgres_changes`
silently dropped every postgres callback.
- SDK-2673, #1928: `channel.join()` nested the config twice and left out
the access token.
- SDK-2674, #1926: `create_client()` didn't type-check the URL and key.
- SDK-2675, #1927: `strip_nulls()` combined with `csv()` was only
rejected in one call order.
- SDK-2676, #1930: removed the unused `_leave_open_topic()`.

Refs SDK-2666


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Tests**
* Expanded synchronous and asynchronous coverage for authentication
flows, session handling, JWT verification, refresh behavior, and
OAuth/PKCE scenarios.
* Added checks for database API requests, response and error handling,
retry behavior, realtime channels and presence, and vector storage
operations.
* Added client-level checks for authorization fallback and realtime
channel access.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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