Skip to content

refactor(realtime)!: remove the automatic REST fallback in send() - #1698

Merged
spydon merged 3 commits into
mainfrom
lukasklingsbo/sdk-1469-v3-remove-the-automatic-rest-fallback-in-realtimechannelsend
Aug 13, 2026
Merged

spydon merged 3 commits into
mainfrom
lukasklingsbo/sdk-1469-v3-remove-the-automatic-rest-fallback-in-realtimechannelsend

Conversation

@spydon

@spydon spydon commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

What

RealtimeChannel.send() used to silently post the broadcast to the legacy /api/broadcast endpoint whenever the channel could not push over the socket (canPush == false), logging a warning that the fallback would be deprecated. It is gone.

  • sendBroadcastMessage() only ever sends over the WebSocket.
  • Calling it on a channel that was never subscribed now throws instead of quietly switching transport.
  • Messages sent between subscribe() and the join completing are still buffered and flushed on join.
  • httpSend() is the explicit REST path and works without subscribing.

The dead _broadcastBody() helper went with it. broadcastEndpointURL and _broadcastHeaders are still used by httpSend().

Why

The fallback made delivery depend on socket timing, so the same call could take two different transports with two different sets of failure modes. Now that httpSend() exists as the explicit REST delivery path, the implicit one is not needed.

Changes

  • packages/realtime_client/lib/src/realtime_channel.dart: drop the fallback branch and the _broadcastBody() helper, and document that sendBroadcastMessage() requires a subscribed channel while httpSend() does not.
  • packages/realtime_client/test/channel_test.dart: the fallback test is replaced by one asserting send() throws when the channel was never subscribed, plus a new test covering the buffered-while-joining path.
  • MIGRATION.md: v2 to v3 entry with the before/after for both transports.
  • sdk-compliance.yaml: note the deviation from supabase-js, which still has the fallback in send(). Also drops the stale note on realtime.channel.broadcast_http, which described the endpoint shape from before httpSend() moved to the per-event URL.

Breaking change

Code that called sendBroadcastMessage() on a channel it never subscribed to relied on the REST fallback and now throws. Switch those calls to httpSend(), which requires a Realtime server running v2.97.0 or newer.

Closes #1600

Summary by CodeRabbit

  • New Features

    • Broadcast messages now use WebSocket delivery through subscribed channels.
    • Added explicit REST delivery through httpSend(), requiring Realtime server v2.97.0 or newer.
  • Bug Fixes

    • Messages sent while a channel is joining are buffered and delivered after connection.
    • Sending through an unsubscribed channel now reports an error instead of falling back to REST.
  • Documentation

    • Added migration guidance covering the updated delivery behavior and server requirements.

`send()` posted the broadcast to the legacy `/api/broadcast` endpoint
whenever the channel could not push over the socket, logging a warning
that the behaviour would be deprecated. It made delivery depend on socket
timing, so the same call could take two transports with two different sets
of failure modes.

Broadcasts now only go over the WebSocket, and `httpSend()` is the
explicit REST path. Messages sent between `subscribe()` and the join
completing are still buffered and flushed on join, so only channels that
were never subscribed throw.

Closes #1600
@spydon spydon added the v3 label Aug 12, 2026
@spydon
spydon requested a review from a team as a code owner August 12, 2026 13:03
@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 700e0aad-d15e-4243-ae37-8952a44ea6b6

📥 Commits

Reviewing files that changed from the base of the PR and between 1119ca1 and c7860d4.

📒 Files selected for processing (1)
  • sdk-compliance.yaml
💤 Files with no reviewable changes (1)
  • sdk-compliance.yaml

📝 Walkthrough

Walkthrough

RealtimeChannel.send() no longer falls back to REST. It sends through WebSocket, buffers messages during joining, and rejects sends before joining. httpSend() is the explicit REST path. Documentation and compliance notes describe the updated behavior.

Changes

Realtime broadcast delivery

Layer / File(s) Summary
WebSocket send behavior
packages/realtime_client/lib/src/realtime_channel.dart, packages/realtime_client/test/channel_test.dart
send() always creates a WebSocket push. Messages sent during joining are buffered, while sends before joining throw an error. Tests cover both behaviors.
Broadcast delivery documentation
MIGRATION.md, packages/realtime_client/lib/src/realtime_channel.dart, sdk-compliance.yaml
Documentation identifies httpSend() as the explicit REST path and records subscription requirements, join buffering, and the minimum server version.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RealtimeChannel
  participant WebSocket
  participant RealtimeServer
  RealtimeChannel->>WebSocket: Create broadcast push
  WebSocket->>RealtimeServer: Send after phx_join acknowledgement
  RealtimeServer-->>WebSocket: Return push response
  WebSocket-->>RealtimeChannel: Resolve or reject send
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main breaking change: removing automatic REST fallback from Realtime broadcast sending.
Linked Issues check ✅ Passed The changes remove the automatic REST fallback and document and test explicit httpSend() usage as required by issue #1600.
Out of Scope Changes check ✅ Passed The migration guide, tests, and SDK compliance update directly support the fallback removal and related v3 behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch lukasklingsbo/sdk-1469-v3-remove-the-automatic-rest-fallback-in-realtimechannelsend

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

Comment @coderabbitai help to get the list of available commands.

@spydon
spydon merged commit 111da28 into main Aug 13, 2026
38 checks passed
@spydon
spydon deleted the lukasklingsbo/sdk-1469-v3-remove-the-automatic-rest-fallback-in-realtimechannelsend branch August 13, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v3: remove deprecated automatic REST fallback in RealtimeChannel.send()

3 participants