realm-js/lib
Mark Rowe c2de29ab0c Fix an issue where `Realm.open` would complain about the Realm already
being open with a different schema version

In order to correctly open read-only synchronized Realms, `Realm.open`
would open the Realm without specifying a schema or schema version, wait
for any remote changes to be downloaded (if appropriate), and then
re-open the Realm with the specified schema and schema version. This
would lead to an exception about the Realm being open with a different
schema version if the Realm had previously been opened with a different
schema version, due to the way `RealmCoordinator` caches information
about the schema of open Realms.

We address this by making two changes:
1. `Realm.open` for non-synchronized Realms no longer goes through
`_waitForDownload`. This means the dance described above where the Realm
is opened twice is not used for local Realms.
2. `_waitForDownload` no longer keeps the `Realm` alive until after its
callback has returned. It instead keeps the `SyncSession` alive. This is
sufficient to avoid the connection being torn down and having to
reconnect when `_waitForDownload`'s callback later opens the Realm with
the correct schema and schema version, while also allowing for
`RealmCoordinator`'s cached information to be cleared when the
schemaless Realm is closed prior to the Realm being reopened.

In addition, tests have been added that reproduced the problem in both a
local and sync context.
2017-12-18 14:54:08 -08:00
..
browser Adding property Realm.isClosed. (#1560) 2017-12-13 10:09:26 +01:00
.eslintrc.json Bumped version of ESLint, added eslinting of specs, make all linting pass 2016-11-14 10:48:50 -08:00
.npmignore Ignore more things when publishing with NPM 2016-01-22 16:43:53 -08:00
collection-methods.js Frozen results during iteration. (#1368) 2017-10-02 23:15:19 +02:00
errors.js Fix IncompatibleSyncedRealm support 2017-09-29 21:43:04 +03:00
extensions.js Fix an issue where `Realm.open` would complain about the Realm already 2017-12-18 14:54:08 -08:00
index.d.ts Add disableFormatUpgrade to Realm configuration (#1566) 2017-12-14 07:53:03 +01:00
index.js remove uneccessary blank line 2017-10-25 18:16:59 +02:00
management-schema.js Alignment of permission schemas with ROS 2 (#1344) 2017-09-26 11:23:36 +02:00
permission-api.js Remove configuration handling from `Realm._waitForDownload` 2017-10-10 21:16:23 -07:00
submit-analytics.js Check for REALM_DISABLE_ANALYTICS earlier in submit-analytics.js 2017-10-10 16:27:32 -07:00
user-methods.js Checking the content-type of authentication responses (#1556) 2017-12-07 10:36:24 +01:00