Skip to content

Commit

Permalink
Fix for #4150: crash when closing Electron app with custom sync error…
Browse files Browse the repository at this point in the history
… handler (#4237)

This follows the pattern from d4d6eab to prevent destruction of the functor
  • Loading branch information
tomduncalf authored Jan 20, 2022
1 parent d02b4ce commit d4e4faf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit d4e4faf

Please sign in to comment.