Repository navigation
fix(realtime): confirm subscribe on the join reply unless waitsForSubscription is set - #1869
Conversation
…scription is set With waitsForSubscription false, subscribe() waited for the "Subscribed to PostgreSQL" system message. realtime-js reports SUBSCRIBED on the join reply, and the server sends that message after the reply and retries most setup errors, so one error is not final. subscribe() now returns on the join reply ok. A later system ok or error is delivered as postgresChangesReady or postgresChangesFailed(_:) and the channel stays subscribed. With waitsForSubscription true, the server holds the reply until the bindings are live and refuses the join on failure. The live query channel sets waitsForSubscription so its first fetch does not start before changes are live.
|
No actionable comments were generated in the recent review. Summary
Change: Bug fix Merge Risk:
|
Coverage Report for CI Build 44399892263Coverage decreased (-0.03%) to 96.176%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions5 previously-covered lines in 2 files lost coverage.
Coverage Stats
💛 - Coveralls |
…resubscribed timing
Problem
With
waitsForSubscriptionfalse (the default),subscribe()waited for the "Subscribed to PostgreSQL"systemmessage whenever the channel had Postgres changes bindings. Asystemerror, or no message in time, failed the subscribe and left the channel.That does not match realtime-js or the server:
SUBSCRIBEDon the join replyok. It passessystemmessages only toon('system')listeners.postgres_changes_options.wait, the Realtime server repliesokat once and sets up the bindings after that. On failure it sends asystempostgres_changeserror, and for most errors it tries again every 5–10 s. So one error is not final.wait, the server holds the reply until the bindings are live and refuses the join itself on failure or timeout.Change
okconfirms the join. The SDK's own wait is removed: the.postgresjoin stage, its timer, and the internalpostgresChangesTimeouterror.systemok or error after the join reachesevents()aspostgresChangesReadyorpostgresChangesFailed(_:). The channel stays subscribed.waitsForSubscriptiontrue, behavior is the same as before: the server holds the reply, andsubscribe()throws if the bindings cannot be set up.SupabaseClient+Stream.swift) setswaitsForSubscription = true, so its first fetch does not start before changes are live.subscribe(),waitsForSubscriptionandsubscriptionTimeoutdescribes the two modes.subscribe()waits for Postgres changes" silent change. This PR reverts that v3 change, so v2 behavior stays.No public symbol changes, so
sdk-compliance.yamlis unchanged.Tests
systemok or error after the join (event only), asystemok before the reply, and a late reply for a timed-out join.waitsForSubscriptionmakessubscribe()throw for a refused binding.RealtimeTests+SupabaseTests: 824 pass.RealtimeIntegrationTests: 42 pass on a local stack.format.sh,swiftlint lint --strict,spell-check.shandcheck-compliance.share clean.