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

Hot reload of a flexible sync app can cause a crash #4506

Closed
sync-by-unito bot opened this issue Apr 20, 2022 · 1 comment · Fixed by #4509
Closed

Hot reload of a flexible sync app can cause a crash #4506

sync-by-unito bot opened this issue Apr 20, 2022 · 1 comment · Fixed by #4509
Assignees

Comments

@sync-by-unito
Copy link

sync-by-unito bot commented Apr 20, 2022

  • [BUG] (Andrew) Just for js-sdk.  Hot reload of a sync app can cause a crash: terminating with uncaught exception of type realm::MultipleSyncAgents: Multiple sync agents attempted to join the same session.  This happened when sync was not enabled in the backend and Realm.open was not returning anything (reproduction)

Investigate issue before continuing to determine level of effort

@sync-by-unito
Copy link
Author

sync-by-unito bot commented Apr 20, 2022

➤ On 2022-04-13, Tom Duncalf commented:

This is caused by the previous sync session not being closed when the new React Native JS thread starts up.

This can happen because the closing of the sync session does not occur immediately, but instead after upload completion: https://github.com/realm/realm-core/blob/master/src/realm/object-store/sync/sync_session.cpp#L115. In Andrew's case, upload will never complete because sync has been disabled, but this is a race condition which can also be hit in other scenarios.

After discussing with Jonathan and Kræn, it seems like a reasonable solution would be to close the sync session immediately when reloading, as we do when session stop policy is "immediate": https://github.com/realm/realm-core/blob/master/src/realm/object-store/sync/sync_session.cpp#L794. This will require finding or exposing functionality from core to immediately shut down any open sync sessions regardless of session stop policy, which we can then call from the RJSInvalidateCaches function which is called when a reload occurs: https://github.com/realm/realm-js/blob/master/src/jsc/jsc_init.cpp#L60

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant