realm / realm-object-server

Tracking of issues related to the Realm Object Server and other general issues not related to the specific SDK's
https://realm.io
293 stars 42 forks source link

Switching user and subsequently open a Realm asynchronously fails #367

Closed Taco55 closed 6 years ago

Taco55 commented 6 years ago

Goals

Log out and log in as a different user with subsequent opening a synced (non-global) Realm via asyncOpen.

Expected Results

Be able to switch a user and successfully open a realm asynchronously.

Actual Results

Error Domain=io.realm.sync Code=4 "Cannot asynchronously open synced Realm, because the associated session previously experienced a fatal error" UserInfo={NSLocalizedDescription=Cannot asynchronously open synced Realm, because the associated session previously experienced a fatal error}

This error seems to be introduced some versions ago when RLMRealm.mm was updated.

Steps to Reproduce

Code Sample

Issue seems similar to #214 despite it has already been closed by @dhmspector.

Properly logging out with SyncUser.current?.logOut() does not make any difference.

Error occurs after successful logging and opening a Realm:

Realm.asyncOpen(configuration: config) { realm, error in
print(error)
 }

Version of Realm and Tooling

Taco55 commented 6 years ago

Problem was related with using incorrect Realm configurations (i.e. with the identity of the user previously logged in, instead of the current user).