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

Fix for #4150: crash when closing Electron app with custom sync error handler #4237

Merged
merged 1 commit into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ x.x.x Release notes (yyyy-MM-dd)
### Fixed
* Opening a Realm with a schema that has an orphaned embedded object type performed an extra empty write transaction. ([realm/realm-core#5115](https://github.com/realm/realm-core/pull/5115), since v10.5.0)
* Schema validation was missing for embedded objects in sets, resulting in an unhelpful error being thrown if the user attempted to define one. ([realm/realm-core#5115](https://github.com/realm/realm-core/pull/5115))
* Fixed a crash when closing an Electron app with a custom sync error handler ([#4150](https://github.com/realm/realm-js/issues/4150)

### Compatibility
* Removed `deprecated-react-native-listview` from root package.json
Expand Down
7 changes: 6 additions & 1 deletion src/js_sync.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ class SyncSessionErrorHandlerFunctor {
: m_ctx(Context<T>::get_global_context(ctx))
, m_func(ctx, error_func)
{
#if defined(REALM_PLATFORM_NODE)
// Suppressing destruct prevents a crash when closing an Electron app with a
// custom sync error handler: https://github.com/realm/realm-js/issues/4150
m_func.SuppressDestruct();
#endif
}

typename T::Function func() const
Expand Down Expand Up @@ -289,7 +294,7 @@ class SyncSessionErrorHandlerFunctor {

private:
const Protected<typename T::GlobalContext> m_ctx;
const Protected<typename T::Function> m_func;
Protected<typename T::Function> m_func;
};


Expand Down