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

Improve logout behavior #2019

Open
b-straub opened this issue Jun 21, 2024 · 2 comments
Open

Improve logout behavior #2019

b-straub opened this issue Jun 21, 2024 · 2 comments

Comments

@b-straub
Copy link

Suggestions to improve logout behavior (version 4.0.7)

  • Try to push changes when any and not just indicate unsynced changes in "not force" mode.
  • Improve logout sync behavior.

await db.cloud.sync({purpose: 'pull', wait: true});

when not online an 'error in syncIfPossible()' exception will be thrown here

console.error(`Failed to sync client changes`, error);

but not propagated upstream in order to catch and inform user that logout is not possible.

  • I worked around both issues client side, bu having something working out of the box would be nicer.
@dfahlander
Copy link
Collaborator

Thanks!

Basically a logout should be a client action only - it deletes the database and then tries to do an initial sync based on anonymous user to get schema and public data in sync. If this sync fails, user is still technically logged out but hasn't got public data from the server yet. But as soon as the app goes online again it should do the initial sync.

Is the bug happening when client is offline, there are unsynced changes, and user choose to log out? Does it leave the db in a buggy state?

@b-straub
Copy link
Author

  • I have a solution for my request WebPush for DexieCloud Feature Request #1986, which requires writing some database entries when the user is about to log out. Actually I could solve this client side, but when inspecting the cloud add-on code, I thought it would be nice to push any pending changes before the actual logout. This may be necessary if a table write is immediately followed by the logout request.
  • In fact, the bug happens when offline. Again, this could be solved client-side, but I think it might be good practice not to block an asynchronous operation when a potentially valid state occurs. I suggest propagating the described error upstream to catch and inform the user.

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

2 participants