Commit Graph

45 Commits

Author SHA1 Message Date
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
blagoev ba2309a540 revert the promise resolve 2017-11-13 23:31:33 +02:00
blagoev f10df2164c fix RN Android debugger 2017-11-13 14:19:59 +02:00
Mark Rowe 0249722a02 Remove configuration handling from `Realm._waitForDownload`
There's no reason for `_waitForDownload` to be responsible for
constructing a new Realm instance when we can instead use the
constructor for that. This eliminates the potential for different
handling of the Realm configuration between `_waitForDownload` and `new
Realm`, which was responsible for various issues (#1391, #1392, #1393).
In turn, this requires that `_waitForDownload` become an instance method.

In addition, we update `Realm.openAsync` and `getSpecialPurposeRealm` to
delegate to `Realm.open` rather than reimplementing equivalent logic
themselves.

Finally, the private mechanism for registering a download progress
handler as part of the sync configuration (`_onDownloadProgress`) is
removed in favor of the public API (`progress()` on the promise returned
by `Realm.open`).
2017-10-10 21:16:23 -07:00
blagoev aefd81ccf7 Kneth/fix partial sync (#1383)
* fix typo in subscribeToObjects
* Fix partial sync test
* Swap error and result order in callback
* Use correct url
2017-10-04 11:28:50 +02:00
Kenneth Geisshirt 7c5572b451 Removing deprecated setAccessToken(). (#1371) 2017-10-02 21:03:29 +02:00
Kenneth Geisshirt feb59ae859 Partial sync (#1361) 2017-10-02 20:29:36 +02:00
Kenneth Geisshirt fe121ea27b Client reset (#1341) 2017-10-02 19:44:24 +02:00
blagoev 6e016b3e69 Remove dead code 2017-10-01 12:23:04 +03:00
blagoev 6d9f85759e Fix IncompatibleSyncedRealm support 2017-09-29 21:43:04 +03:00
Kenneth Geisshirt b1fb8ece57 Fix typo 2017-09-23 10:37:15 +02:00
Kenneth Geisshirt 39fe8c6280 Creating a proper IncompatibleSyncedRealmError class. 2017-09-23 00:05:33 +02:00
Kenneth Geisshirt 8606d37141 Fixes to issues reported by eslint (#1313) 2017-09-14 10:35:02 +02:00
blagoev 064b487c07 Merge branch 'master' into blagoev/promise3 2017-09-13 14:27:04 +03:00
blagoev f7db865458 Fix typescript definitions
Fixes #1306
2017-09-13 12:37:44 +03:00
Maximilian Alexander 78515e3b48 adding promisified apis 2017-09-12 20:10:52 +03:00
blagoev 0214dff951 fix possible hang on iOS 2017-09-11 15:50:44 +03:00
blagoev e1cebe073a add progress notifications api 2017-09-11 15:50:44 +03:00
Kenneth Geisshirt 0c61716c08 Fix accessToken (#1275) 2017-09-01 11:53:52 +02:00
Kenneth Geisshirt 8d7eac1b65 Fix linter error (#1271) 2017-08-31 10:18:10 +02:00
blagoev fad3b369dc fix bad term 2017-08-15 12:36:15 +03:00
blagoev 86999412f0 Depreciate setAccessToken
rename setAccessToken to setFeatureToken
expose both functions while setAccessToken is depreciated
Trim token argument string
2017-08-15 12:36:15 +03:00
Nikola Irinchev bbe62c361b
Don’t execute callback in Realm.open either 2017-07-18 11:28:33 +03:00
Nikola Irinchev bd10a6d8e0
Don’t invoke openAsync callback twice 2017-07-18 00:16:25 +03:00
Yavor Georgiev b1d23bb782
Realm.open and Realm.openAsync should try/catch opening the realm
and pass the error on to the promise and callback respectively so that it can be handled by the caller
2017-07-11 17:47:10 +02:00
Yavor Georgiev 7086ed745f Do not throw when the Sync constructor isn’t there (#1086)
* Do not throw when the Sync constructor isn’t there

with unified packaging it’s there all the time now

Closes #1084
Fixes #996

* Fix running the sync tests when Sync is disabled
2017-06-20 15:40:54 +02:00
Kristian Dupont af72770094 Replace calls to sync.cleanup with sync.removealllisteners (#1066) 2017-06-14 12:54:47 +02:00
blagoev a0f963775b Fix download api for RN
fix tests when run in RN
2017-05-17 16:09:19 +03:00
blagoev 0d3fbccbe1 forgotten file 2017-05-17 16:09:05 +03:00
blagoev 4b67d883b6 Add a fix for RN hang with promises 2017-05-17 16:08:42 +03:00
blagoev 4aecf90176 enable all session-tests and Realm.openAsync 2017-05-17 16:08:24 +03:00
blagoev 315b8c1a7a Fix download api to wait correctly using schema less realm
Added tests using two processes (nodes only)
2017-05-17 16:08:01 +03:00
blagoev 4e77bf326f fix Realm.open to use the correct ctor function 2017-05-17 16:07:35 +03:00
blagoev 216484aede Initial download api support 2017-05-17 16:07:08 +03:00
Kristian Dupont f551a51acc Add missing sync error (#925)
* Add missing sync error

* Make unit tests work without sync

* Wording fix
2017-03-22 13:52:41 +01:00
Radu Tutueanu 716201a1fe Fix loading the constructor for node-server-sdk 2017-02-08 13:36:43 +01:00
Yavor Georgiev 19f00e1b4b Rework #832 (#833) 2017-02-02 02:41:11 +01:00
Yavor Georgiev 408f5588f8 Add Permissions models and User Management Realm API (#824)
* Add Permissions models and User Management Realm API

* docs and changelog

* fix bad merge

* add test

* fix jsdoc annotation

* rename permissions to management schema
2017-01-31 22:56:09 +01:00
Ari Lazier 0238e8fa48 lint fix 2016-11-21 15:33:37 -08:00
Ari Lazier ec2622ba96 call cleanup on exceptions and ctr-c 2016-11-20 10:34:13 -08:00
Søren Vind 06d277aacd Bumped version of ESLint, added eslinting of specs, make all linting pass 2016-11-14 10:48:50 -08:00
Ari Lazier 92adb669d5 hook up new object store apis 2016-10-26 17:00:46 -07:00
Ari Lazier 0d74c05366 add sync cleanup method 2016-10-25 15:04:58 -07:00
Yavor Georgiev 622482029a Pass AuthError in Realm.Sync.User methods callbacks (#619)
* Pass AuthError in Realm.Sync.User methods callbacks

The new Realm.Sync.AuthError class exposes properties common to the Problem family of classes in the Realm Object Server

* extract AuthError in a separate file

* whitespace
2016-10-25 00:12:12 +02:00
Yavor Georgiev 3dc968cfe2 rename wireup 2016-10-11 00:45:01 +02:00