Cannot reopen a closed realm


#1

I can’t seem to open a realm that has previously been closed. I’m using Realm.open(config), with the same configuration, but the promise never resolves or rejects when i try to reopen the realm.

On realm react native 1.13 and realm object server 1.8.3


#2

Hi Tamy,
We need much more information to be able to help you. Check and compare with our samples first, and if that doesn’t help, then reduce your code to the absolute minimum. If you still have problems, please make a reproduction case so we can help you.

Thanks!
Brian


#3

Here’s what i’m using to open and close the realm. I can open the realm, make a query, close it. The next call to open() doesn’t get any success or failure. Trying to make a query get the “Cannot access realm that has been closed” error.

open: function() {
    Realm.open({
      schema: [User, RankTitle, Interest, LocationHistory, PlanHistory],
      sync: {
        user: Realm.Sync.User.current,
        url: 'realm://.../d8318b03386d26e4e290d3d4ee9e3d35/dora'
      }
    }).then((realm) => {
     console.log('open success');
      RealmService.realm = realm;
    }).catch((error) => {
      console.log('open error ' + JSON.stringify(error));
      RealmService.realm = null;
    });
  },
  close: function() {
    RealmService.realm.close();
    RealmService.realm = null;
  },

This is on an android device running 7.0. Haven’t tried on ios or the ios simulator yet.


#4

I can reproduce this on a bare React Native project.
Android Nougat 7.0
realm 1.13
realm object server 1.8.3
react native 0.46.4