Repository navigation
Conversation
A phx_error for the current join now makes the channel wait and join again with the rejoin backoff (1, 2, 5, then 10 s), as supabase-js does. A subscribed channel reports .resubscribing with the new RealtimeError.Kind.channelError and emits .resubscribed when the rejoin is confirmed. Pushes that wait for a reply fail with channelError. A phx_error during a join counts as a failed attempt, so subscribe() keeps waiting. A phx_error for a stale join_ref changes nothing, and phx_close still drops the channel. BREAKING CHANGE: a channel no longer becomes .unsubscribed after a server phx_error, and subscribe() no longer throws channelClosedByServer for one. See docs/migrations/v3/Realtime.md. Fixes SDK-2609
|
Warning Review limit reachedYou'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 4 minutes. View limit details
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. |
|
The following capabilities are marked
These may have been renamed, removed, or never registered. Please update the capability matrix. |
Coverage Report for CI Build 42094534585Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage decreased (-0.01%) to 95.62%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
What and why
A joined
RealtimeChanneldid not rejoin after the server sentphx_errorfor its current join. It went to.unsubscribed, and its streams stayed open but got no data. supabase-js rejoins with its rejoin backoff. This PR makes Swift do the same:RealtimeError.Kind.channelError. It moves to.resubscribing(attempt: 1, retryIn: 1s, lastError: channelError)and joins again withRealtimeChannel.rejoinBackoff(1, 2, 5, then 10 s). A confirmed rejoin emits.resubscribed.phx_errorcounts as a failed attempt, sosubscribe()keeps waiting instead of throwingchannelClosedByServer.phx_errorfor a stalejoin_refis dropped, andphx_closestill drops the channel.In the core,
phx_errornow has its own handler,receiveChannelError, which reusesjoinAttemptFailed. The DocC (ConnectionBehavior.md,Lifetime.md,subscribe()) and the v3 migration guide ("Silent changes" in docs/migrations/v3/Realtime.md) describe the new behavior.sdk-compliance.yamllists the new kind.Spec: the matching rule is in supabase/sdk#334, which is stacked on supabase/sdk#304.
Test evidence
RealtimeCoreLeaveTests: subscribed and joining cases, backoff on a second error, a repeated error during the wait, aphx_errorfor a timed-out join, andunsubscribe()during the wait.ServerErrorRejoinTests, runs the full path onRealtimeTestHostwith a test clock (no real sleeps):phx_error, the rejoin wait, the rejoin, and.resubscribed. It also checks that a pending push fails withchannelError..unsubscribed.swift test --filter RealtimeTests(macOS flags):Test run with 726 tests in 55 suites passed ... with 7 known issues(the 7 known issues were there before this change).swiftlint lint --strict,./scripts/format.sh,./scripts/spell-check.sh, and./scripts/check-compliance.share clean.phx_erroron demand, so the test host plays the server.Fixes SDK-2609