Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crash in Realm.deleteFile, Realm.exists, Realm.schemaVersion, Realm.determinePath, Realm.transformConfig and User#isLoggedIn #6662

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
* None

### Enhancements
* None
* Nested collections have full support for automatic client reset ([realm/realm-core#7683](https://github.com/realm/realm-core/pull/7683)).

### Fixed
* Fixed a crash experienced on React Native when accessing `Realm.deleteFile`, `Realm.exists`, `Realm.schemaVersion`, `Realm.determinePath`, `Realm.transformConfig` and `User#isLoggedIn`. ([PR #6662](https://github.com/realm/realm-js/pull/6662), since v12.8.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Fixed a crash experienced on React Native when accessing `Realm.deleteFile`, `Realm.exists`, `Realm.schemaVersion`, `Realm.determinePath`, `Realm.transformConfig` and `User#isLoggedIn`. ([PR #6662](https://github.com/realm/realm-js/pull/6662), since v12.8.0)
* Fixed a crash experienced on React Native when accessing `Realm.deleteFile`, `Realm.exists`, `Realm.schemaVersion`, `Realm.determinePath`, `Realm.transformConfig` and `User#isLoggedIn`. ([#6662](https://github.com/realm/realm-js/pull/6662), since v12.8.0)

* Accessing `App#currentUser` from within a notification produced by `App#switchUser` or `App#logIn` would deadlock ([realm/realm-core#7670](https://github.com/realm/realm-core/issues/7670), since v12.8.0).
* Inserting the same typed link to the same key in a dictionary more than once would incorrectly create multiple backlinks to the object. This did not appear to cause any crashes later, but would have affecting explicit backlink count queries (eg: `...@links.@count`) and possibly notifications ([realm/realm-core#7676](https://github.com/realm/realm-core/issues/7676) since v12.7.1).
* Having links in a nested collections would leave the file inconsistent if the top object is removed. ([realm/realm-core#7657](https://github.com/realm/realm-core/issues/7657), since v12.7.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nested collections shouldn't have been released, so this issue shouldn't have affected JS users.

* Automatic client reset recovery would crash when recovering AddInteger instructions on a Mixed property if its type was changed to non-integer ([realm/realm-core#7683](https://github.com/realm/realm-core/pull/7683), since v10.18.0).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not exposed in the JS (or any other) SDK, so users shouldn't have been affected.

* <How to hit and notice issue? what was the impact?> ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?)
* None

### Compatibility
* React Native >= v0.71.4
Expand Down
5 changes: 3 additions & 2 deletions packages/realm/bindgen/js_opt_in_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ classes:
- make_ssl_verify_callback
- needs_file_format_upgrade
- sync_user_as_app_user
- app_user_as_sync_user

LogCategoryRef:
methods:
Expand Down Expand Up @@ -446,7 +447,8 @@ classes:
- api_key

SyncUser:
methods: []
methods:
- is_logged_in

User:
methods:
Expand All @@ -459,7 +461,6 @@ classes:
- unsubscribe
- path_for_realm
- app
- is_logged_in
- user_id
- app_id
- legacy_identities
Expand Down
5 changes: 4 additions & 1 deletion packages/realm/src/app-services/SyncConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,11 @@ export function toBindingSyncConfig(config: SyncConfiguration): binding.SyncConf
proxyConfig,
} = config;

const syncUser = binding.Helpers.appUserAsSyncUser(user.internal);
assert(syncUser);

return {
user: user.internal,
user: syncUser,
partitionValue: flexible ? undefined : EJSON.stringify(partitionValue),
flxSyncRequested: !!flexible,
stopPolicy: _sessionStopPolicy
Expand Down
4 changes: 3 additions & 1 deletion packages/realm/src/app-services/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ export class User<
* @returns `true` if the user is logged in, `false` otherwise.
*/
get isLoggedIn(): boolean {
return this.internal.isLoggedIn;
const syncUser = binding.Helpers.appUserAsSyncUser(this.internal);
assert(syncUser);
return syncUser.isLoggedIn;
}

/**
Expand Down
Loading