-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
How to handle client reset error in SwiftUI Realm app #7881
Comments
I tried adding this to my app:
and then adding this line to my OpenSyncedRealmView:
...but although it does appear to attempt to delete all the realm files, it also kills my app with a terminal fault, and after restarting I still get the ErrorView containing the "Bad Client File Identifier (IDENT)..." message as noted above. |
You probably know this, but have you tried using our new feature for client reset, you can set it to .manual or .discardLocal https://www.mongodb.com/docs/realm/sdk/swift/sync/handle-sync-errors/#:~:text=A%20client%20reset%20discards%20local,0.
|
For your specific example, you will have to create the view again with the autopen property wrapper to be able to inject the new realm. AutoOpen by itself doesn't detect that we handle the client reset and doesn't retries to open the realm. |
Something I don't yet understand about the suggestion above, which seems great if I could fully grasp it:
although in your example you use |
I'm trying this now, maybe this is going to work:
|
I have distilled a solution that seems to be working for me to recover from a client reset error state into a minimal example. I would very much like and appreciate code review and pointing out anything that I might have missed or might consider doing differently. Thank you.
in a SwiftUI app:
|
@drmarkpowell Yes, thanks! The Example for others:
and in
|
Hi @drmarkpowell the way you inject the configuration into the |
Hey @drmarkpowell is this info good enough for you, do you need more help with this? Let us know so we can close the issue. |
Yes, my implementation looks to be working well so far. Thanks for confirming the approach is viable. Closing. |
How frequently does the bug occur?
All the time
Description
Getting a client reset error in our app, need to remove the local realm and re-open anew automatically for the user when the app enters the .error state in
@AutoOpen
or@AsyncOpen
.Example:
I'm not concerned with backup/restore.
Stacktrace & log output
Can you reproduce the bug?
Yes, always
Reproduction Steps
open a realm
making a breaking schema change
error occurs during client sync
Version
10.28
What SDK flavour are you using?
MongoDB Realm (i.e. Sync, auth, functions)
Are you using encryption?
No, not using encryption
Platform OS and version(s)
iOS 15 lateest
Build environment
Xcode version: 13 latest
Dependency manager and version: SPM
The text was updated successfully, but these errors were encountered: