Observing RLMSyncError in SwiftUi

Trying to set an error handler in SwiftUi to detect and respond to any failed sync-related calls. Unfortunately the by MongoDB proposed method and even the demo app (todolist) does not triggered any sync termination like proposed for testing. But the terminal window reports Info: Connection[1] Received: ERROR “Sync is not enabled for this app” (error_code=101, is_fatal=false, session_ident=0, error_action=Warning)
Info: Connection[1] Connection closed due to error reported by server: Sync is not enabled for this app (101)
Anyone with an idea about that issue?

Hi @Dirk_Bohnes,

the demo app (todolist) does not triggered any sync termination like proposed for testing.

That’s a known behaviour: as the SDK will try to reconnect automatically, at this time it is not considered an error your code needs to act upon. This may change in the future.

In the meantime, if you want to be notified whether Sync is available or not, you can observe the connectionState : a Paused or Terminated Sync (that are the states that will return Sync is not enabled for this app) will cause a disconnection, that will trigger periodic attempts to a reconnection.

Thank you, Paolo.
I assume than, that the proposed method to test client reset handling is not correct? (

  1. Write data from a client application and wait for it to synchronize, 2. Terminate and re-enable Device Sync, 3. Run the client app again. The app should get a client reset error when it tries to connect to the server.)
    Testing a similar situation on Kotlin SDK … throws an error: “io.realm.kotlin.mongodb.exceptions.SyncException: Runtimel Runtime(1000)l Sync is not enabled”

Somehow an inconsistent behavior, or?

Hi @Dirk_Bohnes,

That’s correct, aren’t you experiencing this? The error you’re complaining about should happen only while Sync is still Terminated, and a connection isn’t available. As explained above, the SDK, in both cases, will retry connection periodically, and generate a Client Reset when Sync is fully re-enabled. As per the Client Reset error itself, it depends on the mode you’ve chosen: if it’s Automatic Recovery, then no, you won’t get one.

Correct, however that isn’t a Client Reset error, it’s a different one, notifying that Sync isn’t available. Given enough time, you’ll receive that multiple times, until Sync is back.

Yes, it’s inconsistent across SDKs: some raise an error, some don’t, however the error is marked as non-fatal, the app isn’t supposed to go into panic, and the general behaviour still stands, i.e. the SDK will retry over and over.