Supabase Realtime: first realtime.send (broadcast from database) after a client subscribes to an idle project is never delivered, later ones arrive in 0 ms
On hosted Supabase, a private-channel listener reached SUBSCRIBED, then a database trigger called realtime.send; that first message was never delivered, while every later send arrived in 0 ms. The first join on an idle project starts the tenant, which creates a temporary replication slot on realtime.messages about 1 s later. The slot never replays, so a row inserted before it streams is saved but sent to nobody. Partitions were not the cause. Tests that post right after SUBSCRIBED fail cold and pass warm. Wait until a probe arrives before measuring delivery.
What happened
A test script for a chat feature built on Supabase Realtime "broadcast from database":
- subscribes a signed-out listener to a private channel
chat:test:<random>(Realtime Authorization via RLS onrealtime.messages), waits forSUBSCRIBED; - posts a message through an RPC whose
after inserttrigger callsrealtime.send(payload, 'message', 'chat:test:<random>', true); - waits 3 s for the listener to receive it.
Run against a project that had no Realtime clients for hours, step 3 got nothing. Run again a minute later, the message arrived in 0 ms. A later send in the same cold run (an update broadcast ~10 s after) also arrived in 0 ms. The pattern repeated: both cold runs failed, both warm runs passed.
Timeline from the project's Realtime logs and realtime.messages
(times from one cold run, seconds only)
| t | event |
|---|---|
| 51.68 | Realtime log: Tenant <ref> is initializing (the listener's join woke the tenant; the client already saw SUBSCRIBED shortly after) |
| 52.10 | Creating partitions for realtime.messages |
| 52.548 | realtime.messages.inserted_at of the test message (the insert succeeded) |
| 52.671 | Create replication slot supabase_realtime_messages_replication_slot_... using plugin pgoutput |
| 52.704 | Starting stream replication for slot ... |
| 62.64 | next broadcast (a hide) inserted; delivered in 0 ms |
The message row was inserted 0.12 s before the temporary replication slot existed. A temporary slot starts at the current WAL position, so that row is never streamed. There is no error or warning: the insert succeeded, and WarnSendingBroadcastMessage does not appear (that warning is the missing-partition case; today's partition existed).
Why
Supabase's own troubleshooting page says the replication slot "only starts once a client connects over WebSocket", "is temporary and does not replay history, so it only delivers messages inserted after a client connected". In practice, "connected" means the slot is streaming, which comes roughly a second after the first client's join returns SUBSCRIBED on an idle project.
What to do
- Tests / health checks: don't measure delivery with the first send after subscribing on a possibly idle project. First wait until delivery works: send probe broadcasts (respecting any per-user rate limit in your RPC) until one reaches the listener, with a deadline (e.g. 15 s, after which fail). Report the warm-up time as info, then run the real delivery check. Without this the check fails after every quiet period and passes when re-run, which teaches people to ignore it.
- Apps: the window is only the ~1 s after the first client joins an idle project, so a human typing a message is not affected in practice. If your UI may lose events from that window (e.g. a server event fired the moment a page subscribes), re-fetch from your own table after
SUBSCRIBEDplus a second or two, and dedupe by id. - To see it yourself: Realtime logs around the run (
is initializing,Starting stream replication), andselect topic, event, inserted_at from realtime.messages where topic = '<topic>'(rows remain after your test deletes its own data).
Not the cause here
- Missing daily partition on
realtime.messages: partitions for yesterday through +3 days existed. - RLS / authorization: the same listener received the later broadcast in the same run.
- Client library version: current at the time (below).
Conditions
- service
- Supabase hosted, Realtime broadcast from database, private channels
- supabase_js
- 2.110.7
- realtime_js
- 2.110.7
- replication
- pgoutput, protocol version 2
- node
- 24
- observed
- 2026-11-24 and 2026-11-25
Sources
- Realtime: WarnSendingBroadcastMessage when broadcasting from the database — Says the realtime.messages replication slot starts only once a client connects, is temporary, and does not replay; also covers the separate missing-partition case