Skip to content

fix(realtime): include connection params in WebSocket URL - #1652

Open
hsusul wants to merge 1 commit into
supabase:mainfrom
hsusul:fix/realtime-connection-params
Open

hsusul wants to merge 1 commit into
supabase:mainfrom
hsusul:fix/realtime-connection-params

Conversation

@hsusul

@hsusul hsusul commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • include configured Realtime connection parameters in the WebSocket URL
  • preserve the API key already present in the URL and add the protocol version
  • add a focused regression test at the WebSocket transport boundary

Problem

AsyncRealtimeClient stored its documented params, but connect() opened self.url directly. Supported connection parameters such as log_level and the vsn prepared by endpoint_url() never reached the Realtime server.

Root cause

The URL builder existed but was bypassed by the connection path. It also replaced the URL's existing query string, which would have dropped the API key if used directly.

Solution

Build the endpoint once per connection attempt sequence, preserving existing query parameters before adding configured parameters and vsn, and pass that URL to the WebSocket transport.

Tests

  • regression first: test_connect_includes_connection_params failed on clean main because log_level and vsn were absent
  • uv run --package realtime pytest -o addopts= tests/test_connection.py::test_connect_includes_connection_params -q — 1 passed
  • make tests in src/realtime — mypy passed and 32 tests passed using the Supabase CLI service containers

Validation

  • uv run ruff check src/realtime — passed
  • uv run ruff format --check src/realtime — 21 files already formatted
  • uv build --package realtime — source distribution and wheel built successfully
  • git diff --check — passed

Compatibility and risk

The public API is unchanged. Existing API-key authentication is preserved; callers that provide connection parameters now get the documented behavior. The sync Realtime client is unchanged because it does not implement connections.

Documentation

No documentation change is needed because this restores the existing params contract.

Fixes #1651

cc @olirice @silentworks

@hsusul
hsusul requested review from a team and o-santi as code owners September 19, 2026 18:43

This branch has not been deployed

No deployments
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.

Realtime connection params are omitted from the WebSocket URL

1 participant