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

This follows the pattern from d4d6eab to prevent destruction of the functor
  • Loading branch information
Tom Duncalf committed Jan 20, 2022
1 parent d02b4ce commit 1b6b974
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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
2 changes: 1 addition & 1 deletion vendor/realm-core
Submodule realm-core updated 152 files

0 comments on commit 1b6b974

Please sign in to comment.