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

App doesn't emit a state change on logout while offline. #6806

Open
sync-by-unito bot opened this issue Jul 19, 2023 · 6 comments
Open

App doesn't emit a state change on logout while offline. #6806

sync-by-unito bot opened this issue Jul 19, 2023 · 6 comments

Comments

@sync-by-unito
Copy link

sync-by-unito bot commented Jul 19, 2023

While logging out an anonymous user while offline, I see the following in OS # First, the user is logout, meaning the state changes to State::LoggedOut

  1. Because it is an anonymous user, we mark the user as dead and change the state to State::Removed
  2. We then do the request to the server to logout, and because we don't have a connection this throws an error
  3. Because the server throws an error, we are not submitting any changes to the app subscribers, even though we already removed the user from the sync metadata,

Is this the intended behaviour?, Even though the request is failing wouldn't we need to inform to the app subscribers that the current user state changed?

Original issue: realm/realm-swift#8302

@kiburtse
Copy link
Contributor

@dianaafanador3 in the original issue it's mentioned that it's crashing due to unhandled exception, right? Is it in sdk code or somewhere in core?

@michael-wb @danieltabacaru could you comment on this usecase?

@dianaafanador3
Copy link
Contributor

The issue here is that their UI is not updating because they are expecting the app subscriber to emit some notification if the App state changes, in this particular case the user is logout and removed even though the request to the server throws an error (Offline error), and then when they are trying to add an object they get the following error terminating with uncaught exception of type std::logic_error: Cannot start a sync session for user '64b06b2c314e2e772278412c' because this user has been removed. (lldb), I think because there is no longer a user associated to the current sync session.

@michael-wb
Copy link
Contributor

michael-wb commented Jul 21, 2023

Ah - so maybe we need something like force_logout() or force_remove() that "logs out" and deletes the user locally even if there is no online connection. There is the side effect, though, that a stale user will reside in the cloud app until it expires (could be 30 or more days)...

@dianaafanador3
Copy link
Contributor

@michael-wb when we logout an anonymous user, even if the request fails we still logout and remove the user from the sync metadata. So my questions is, does this user change should emit an app notification, because we no longer have an associated user to the app?

@dianaafanador3
Copy link
Contributor

This issue realm/realm-swift#8320, has a different path, but seems to be related to this

Copy link
Author

sync-by-unito bot commented Jan 29, 2024

➤ michael-wb commented:

Will be adding a test to Core to try to reproduce this issue

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

No branches or pull requests

3 participants