Skip to content

Commit

Permalink
RJS-2784: Clear internal state to avoid crashes when React Native app…
Browse files Browse the repository at this point in the history
… is reloaded (#6612)

* Clear internal state to avoid crashes when React Native app is reloaded

---------

Co-authored-by: LJ <81748770+elle-j@users.noreply.github.com>
  • Loading branch information
kneth and elle-j authored Apr 17, 2024
1 parent b88a065 commit 724540c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* `data` and `string` are now strongly typed for comparisons and queries. This change is especially relevant when querying for a string constant on a Mixed property, as now only strings will be returned. If searching for `data` is desired, then that type must be specified by the constant. In RQL the new way to specify a binary constant is to use `mixed = bin('xyz')` or `mixed = binary('xyz')`. ([realm/realm-core#6407](https://github.com/realm/realm-core/issues/6407))
* Fixed diverging history due to a bug in the replication code when setting default null values (embedded objects included). ([realm/realm-core#7536](https://github.com/realm/realm-core/issues/7536))
* Null pointer exception may be triggered when logging out and async commits callbacks not executed. ([realm/realm-core#7434](https://github.com/realm/realm-core/issues/7434), since v12.6.0)
* Fixed a bug which caused crashes when reloading React Native apps. ([#6579](https://github.com/realm/realm-js/issues/6579), since v12.0.0)

### Compatibility
* React Native >= v0.71.4
Expand Down
2 changes: 1 addition & 1 deletion packages/realm/src/Realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,6 @@ export namespace Realm {
export import PushClient = internal.PushClient;
}

//Set default logger and log level.
// Set default logger and log level.
Realm.setLogger(defaultLogger);
Realm.setLogLevel(defaultLoggerLevel);
6 changes: 6 additions & 0 deletions packages/realm/src/platform/react-native/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ import "./device-info";
import "./sync-proxy-config";

import { Realm } from "../../Realm";
import { binding } from "../binding";

// Clear the internal state to prevent crashes when reloading the app
binding.RealmCoordinator.clearAllCaches();
binding.App.clearCachedApps();

export = Realm;

0 comments on commit 724540c

Please sign in to comment.