Skip to content

Commit

Permalink
Upgrade to Realm Core 11.6.0. Was: Adopting to changes in Realm Core …
Browse files Browse the repository at this point in the history
…(past 11.4.1) (#4023)

* Adopting to changes in Realm Core

* Upgrade to Realm Core v10.6.0

* Avoid same lookup twice (#4058)

* Don't lookup twice

Co-authored-by: Kenneth Geisshirt <[email protected]>
Co-authored-by: Kenneth Geisshirt <[email protected]>
  • Loading branch information
3 people authored Nov 10, 2021
1 parent 8b3bd3d commit 535bea5
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 42 deletions.
17 changes: 12 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ x.x.x Release notes (yyyy-MM-dd)
* New consistent API for `EmailPasswordAuth` methods, using a single object dictionary rather than positional arguments, to fix inconsistencies and make usage clearer. The existing API is being deprecated (see above). ([#3943](https://github.com/realm/realm-js/issues/3943))

### Fixed
* <How to hit and notice issue? what was the impact?> ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?)
* None.
* Using `sort`, `distinct`, or `limit` as property name in query expression would cause an `Invalid predicate` error. ([realm/realm-java#7545](https://github.com/realm/realm-java/issues/7545), since v10.0.2)
* Fixed a rare assertion failure or deadlock when a sync session. ([realm/realm-core#4931](https://github.com/realm/realm-core/issues/4931))
* Fixed a rare segfault which could trigger if a user was being logged out while the access token refresh response comes in. ([realm/realm-core#4944](https://github.com/realm/realm-core/issues/4944), since v10.0.0)
* Fixed a user being left in the logged in state when the user's refresh token expires. ([realm/realm-core#4882](https://github.com/realm/realm-core/issues/4882), since v10.0.0)
* Allow for `EPERM` to be returned from `fallocate()`. This improves support for running on Linux environments with interesting file systems, like AWS Lambda. Thanks to [@ztane](https://github.com/ztane) for reporting and suggesting a fix. ([realm/realm-core#4957](https://github.com/realm/realm-core/issues/4957) and [#1832](https://github.com/realm/realm-js/issues/1832))
* Sync progress notifiers would not trigger when the downloadable bytes size would equal 0. ([realm/realm-core#4989](https://github.com/realm/realm-core/pull/4989), since v10.3.0-rc.1)

### Compatibility
* MongoDB Realm Cloud.
Expand All @@ -23,10 +27,13 @@ x.x.x Release notes (yyyy-MM-dd)
* Adding use of [ccache](https://ccache.dev/) in build scripts, XCode projects and the integration tests GHA workflow.
* Dropped using `install-local` in the integration tests, in favour of a more involved Metro configuration.
* Add combined type definition for Realm.object and Realm.objectForPrimaryKey so they can be cleanly wrapped.
* <Either mention core version or upgrade>
* <Using Realm Core vX.Y.Z>
* <Upgraded Realm Core from vX.Y.Z to vA.B.C>
* Upgraded Realm Core from v11.4.1 to v10.5.2.
* Change Apple/Linux temporary directory to default to the environment's `TMPDIR` if available. This is primarily used by tests. ([realm/realm-core#4921](https://github.com/realm/realm-core/issues/4921))
* Adding colorized compiler diagnostics if using Ninja.
* Upgraded Realm Core from v11.4.1 to v10.6.0.
* Change Apple/Linux temporary directory to default to the environment's `TMPDIR` if available. This is primarily used by tests. ([realm/realm-core#4921](https://github.com/realm/realm-core/issues/4921))
* Minor speed improvement in property setters. ([#4058](https://github.com/realm/realm-js/pull/4058) and [realm/realm-core#5011](https://github.com/realm/realm-core/pull/5011))
* Adding use of [ccache](https://ccache.dev/) in build scripts, XCode projects and the integration tests GHA workflow.

10.9.1 Release notes (2021-10-20)
=============================================================
Expand Down
2 changes: 1 addition & 1 deletion dependencies.list
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PACKAGE_NAME=realm-js
VERSION=10.9.1
REALM_CORE_VERSION=11.4.1
REALM_CORE_VERSION=11.6.0
NAPI_VERSION=4
OPENSSL_VERSION=1.1.1g
MDBREALM_TEST_SERVER_TAG=2021-06-01
4 changes: 1 addition & 3 deletions src/js_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ void AppClass<T>::constructor(ContextType ctx, ObjectType this_object, Arguments
throw std::runtime_error("Expected either a configuration object or an app id string.");
}

config.transport_generator = [ctx = Protected(Context::get_global_context(ctx)), eld=NetworkTransport::make_dispatcher()] {
return AppClass<T>::transport_generator(ctx, eld);
};
config.transport = AppClass<T>::transport_generator(Protected(Context::get_global_context(ctx)), NetworkTransport::make_dispatcher());

config.platform = platform_os;
config.platform_version = platform_version;
Expand Down
2 changes: 1 addition & 1 deletion src/js_realm_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ bool RealmObjectClass<T>::set_property(ContextType ctx, ObjectType object, const
throw TypeErrorException(accessor, realm_object->get_object_schema().name, *prop, value);
}

realm_object->set_property_value(accessor, prop->name, value, realm::CreatePolicy::UpdateAll);
realm_object->set_property_value(accessor, *prop, value, realm::CreatePolicy::UpdateAll);
return true;
}

Expand Down
22 changes: 11 additions & 11 deletions src/js_sync.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class SessionClass : public ClassDefinition<T, WeakSession> {
public:
std::string const name = "Session";
using ProgressHandler = void(uint64_t transferred_bytes, uint64_t transferrable_bytes);
using StateHandler = void(SyncSession::PublicState old_state, SyncSession::PublicState new_state);
using StateHandler = void(SyncSession::State old_state, SyncSession::State new_state);
using ConnectionHandler = void(SyncSession::ConnectionState new_state, SyncSession::ConnectionState old_state);
using DownloadUploadCompletionHandler = void(std::error_code error);

Expand Down Expand Up @@ -368,7 +368,7 @@ void SessionClass<T>::get_state(ContextType ctx, ObjectType object, ReturnValue
return_value.set(invalid);

if (auto session = get_internal<T, SessionClass<T>>(ctx, object)->lock()) {
if (session->state() == SyncSession::PublicState::Inactive) {
if (session->state() == SyncSession::State::Inactive) {
return_value.set(inactive);
} else {
return_value.set(active);
Expand Down Expand Up @@ -412,14 +412,14 @@ void SessionClass<T>::add_progress_notification(ContextType ctx, ObjectType this

if (auto session = get_internal<T, SessionClass<T>>(ctx, this_object)->lock()) {

std::string direction = Value::validated_to_string(ctx, args[0], "direction");
std::string direction_str = Value::validated_to_string(ctx, args[0], "direction");
std::string mode = Value::validated_to_string(ctx, args[1], "mode");
SyncSession::NotifierType notifierType;
if (direction == "download") {
notifierType = SyncSession::NotifierType::download;
SyncSession::ProgressDirection direction;
if (direction_str == "download") {
direction = SyncSession::ProgressDirection::download;
}
else if (direction == "upload") {
notifierType = SyncSession::NotifierType::upload;
else if (direction_str == "upload") {
direction = SyncSession::ProgressDirection::upload;
}
else {
throw std::invalid_argument("Invalid argument 'direction'. Only 'download' and 'upload' progress notification directions are supported");
Expand Down Expand Up @@ -455,7 +455,7 @@ void SessionClass<T>::add_progress_notification(ContextType ctx, ObjectType this

progressFunc = std::move(progress_handler);

auto registrationToken = session->register_progress_notifier(std::move(progressFunc), notifierType, is_streaming);
auto registrationToken = session->register_progress_notifier(std::move(progressFunc), direction, is_streaming);
auto syncSession = create_object<T, SessionClass<T>>(ctx, new WeakSession(session));
PropertyAttributes attributes = ReadOnly | DontEnum | DontDelete;
Object::set_property(ctx, callback_function, "_syncSession", syncSession, attributes);
Expand Down Expand Up @@ -536,7 +536,7 @@ void SessionClass<T>::is_connected(ContextType ctx, ObjectType this_object, Argu
auto state = session->state();
auto connection_state = session->connection_state();
if (connection_state == SyncSession::ConnectionState::Connected
&& (state == SyncSession::PublicState::Active || state == SyncSession::PublicState::Dying)) {
&& (state == SyncSession::State::Active || state == SyncSession::State::Dying)) {
return_value.set(true);
}
}
Expand Down Expand Up @@ -755,7 +755,7 @@ void SyncClass<T>::set_sync_logger(ContextType ctx, ObjectType this_object, Argu
};

auto sync_logger = common::logger::Logger::build_sync_logger(show_logs);
app->sync_manager()->set_logger_factory( *sync_logger );
app->sync_manager()->set_logger_factory(sync_logger);
}

template<typename T>
Expand Down
27 changes: 7 additions & 20 deletions src/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,6 @@ class SyncLoggerDelegator : public util::RootLogger {
Delegated loggerDelegate;
};

class SyncLoggerDelegatorFactory : public realm::SyncLoggerFactory {
public:
SyncLoggerDelegatorFactory(Delegated logs_fn) : logs_fn{logs_fn} {}

std::unique_ptr<realm::util::Logger> make_logger(
realm::util::Logger::Level level) {
auto logger = std::make_unique<SyncLoggerDelegator>();

logger->set_level_threshold(level);
logger->delegate(logs_fn);

return logger;
}

private:
Delegated logs_fn;
};

class Logger {
private:
// Warning: If this grows to big (for example: another method) we should
Expand Down Expand Up @@ -157,8 +139,13 @@ class Logger {
throw std::runtime_error("Bad log level");
}

static SyncLoggerDelegatorFactory* build_sync_logger(Delegated& log_fn) {
return new SyncLoggerDelegatorFactory(log_fn);
static SyncClientConfig::LoggerFactory build_sync_logger(Delegated& log_fn) {
return [&log_fn] (realm::util::Logger::Level level) {
auto logger = std::make_unique<SyncLoggerDelegator>();
logger->set_level_threshold(level);
logger->delegate(log_fn);
return logger;
};
}
};

Expand Down
2 changes: 1 addition & 1 deletion vendor/realm-core
Submodule realm-core updated 373 files

0 comments on commit 535bea5

Please sign in to comment.