Repository navigation
Conversation
removeChannel kept the channel in `channels` until the server acknowledged the leave, so a channel(topic) call during that round trip (a React StrictMode remount does this) got back the channel being torn down. It is now dropped as soon as the leave is sent, and _remove filters by identity so the old channel's close hook cannot remove its same-topic replacement. channel() also warns when it returns an existing channel whose params differ from the ones passed, instead of ignoring them silently. Refs supabase#2896
|
No actionable comments were generated in the recent review. Summary
Change: Bug fix Merge Risk:
|
Addresses points 1 and the first half of 3 from #2896. Reference counting is left out, since it changes
removeChannelsemantics and is a maintainer call.What changes
removeChanneldrops the channel right away. It used to stay inchannelsuntil the server acknowledged the leave, so achannel(topic)call during that round trip got back the channel being torn down. A React StrictMode remount does exactly this. The leave is now sent first, then the channel is removed fromchannels, so the nextchannel(topic)builds a fresh one._removefilters by identity, not topic. Without this, the old channel's close hook fires after the new one exists and removes it, because they share a topic.channel()warns on mismatched params. When it returns an existing channel and the passed config differs from that channel's config, it logs aconsole.warninstead of dropping the new params silently. Configs are compared with every default filled in, including insidebroadcastandpresence, so{ broadcast: { self: false } }matches the default. Calling with no params, or with{ config: {} }(which is whatSupabaseClient.channelpasses when the caller gives none), never warns.Leave errors. The existing behaviour is kept: if the server answers the leave with
error, the channel goes back intochannels. The one exception is when a channel for the same topic was created in the meantime. Then the old one is torn down, so the two don't both receive the topic's messages.The empty-channels deferred disconnect is unchanged: the close hook still calls
_remove, which schedules it when nothing is left.Tests
Three new tests in
RealtimeClient.channels.test.tscover a fresh channel during the leave, a warning on different params, and no warning for equivalent, omitted or empty params. The realtime-js suite passes (512 passed, 1 skipped), andnx buildpasses for realtime-js and supabase-js.The unhandled error that
RealtimeChannel.messaging.test.tssometimes reports ("expected 'closed' to be 'joined'") happens on master too, in 2 of 4 runs here, and has nothing to do with this change.