-
Notifications
You must be signed in to change notification settings - Fork 253
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
Datastore - Initial cloud sync failed #4012
Comments
Greetings! I am working on Cashflow, a fintech app built with Flutter and AWS Amplify. It enables collection agents to create customers, manage loan transactions, and collect EMI payments from borrowers in their assigned areas.
Once the release APK is installed, all CRUD (Create, Read, Update, Delete) operations performed should automatically sync data to the cloud. However, if the app is left unused for an extended period or resumes from a detached lifecycle state, syncing issues may occur. For instance, if the app is swiped away, the phone is turned off and on again, and the app is reopened, the data gets stuck in the "Outbox Mutation Enqueued" state, failing to sync with the cloud. To sync local mutations to the cloud, a restart of the app is always required I've attempted various solutions, such as stopping and restarting the Amplify DataStore and reinitializing the plugin at runtime, but the issue persists. Upon my careful observation, I have come to the conclusion that my issue is related to the utilization of a GraphQL schema. Every time data syncing halts just before the "Outbox Mutation Processed" state, It indicates the problem arises when the datastore is interacting with the GraphQL API for data synchronization (resulting in a cessation of cloud syncing due to GraphQL API issues).I noticed that if my mobile device is disconnected from the network, any new customers I create, let's say A and B, are saved locally. When I'm connected to the network again, if there's an error with the GraphQL API, the data for customers A and B doesn't sync with the cloud (I used the DataStore errorHandler parameter to detect errors, but I did not receive any errors from the errorHandler function. Each time, the data stops at outboxMutationEnqueuedEvent). Although I didn't receive any plugin errors, Later, I created two more customers, C and D, and their data is also saved locally. However, after restarting the app, only customers A and B's data is synced, but not customers C and D's (which means that the data created before the plug-in error is retained and synced to the cloud, but the data created after the plug-in error is only retained locally and isn't synced to the cloud) If I reinstall the app, I lose the data for customers C and D.I would greatly appreciate any recommendations or specific steps to address this issue. If you have encountered a similar challenge or have insights that could guide me, please feel free to share. Any additional information you believe would be helpful in resolving this issue is more than welcome. Thank you for your time and assistance in advance! Your guidance is highly valued. |
@cwomack Any update to this? I'm currently just trying to do a workaround where I can signout if I get that final error message: But I'm not even having success doing that. I tried setting up an ApiHubEvent listener but I never get anything from it:
Any suggestions for any way to fix this or do a workaround to at least sign out when the sync doesn't progress? I really need this to get fixed asap. Thanks! |
@cwomack I updated the initial problem statement to include my issue of not being able to handle the error. I would really appreciate a response soon. This is definitely a pain point in our project. |
Looks like this issue is basically the exact same -> #3658 and this issue provides the solution -> aws-amplify/amplify-category-api#1853 However, I would still like to know how to handle that error if I was to see it again in the future (or something like it). |
@khatruong2009 Yes, that solved the sync issue. I would still like to know how to catch that error if I ever see it again though (before closing this ticket). |
Hi @adplant, I would suggest putting a try catch block around the problematic code (probably Datastore.start() or trying to save a model) if you run into anymore issues. |
Description
When I log in to my app the initial sync happens, and it's fairly reliable. Definitely not perfect, but works more than it doesn't first time around.
However, when I stay signed in and just close the app (I'm on Android and swipe away the app so it's not in the background anymore either) something seems to happen b/c when I open the app again and the sync
initiates, but it very frequently gives me this message (see attached).
AppSyncError.txt
What's really a pain point is that I can't seem to handle the error that is thrown from the
datastore
:Categories
Steps to Reproduce
Screenshots
No response
Platforms
Flutter Version
3.13.8
Amplify Flutter Version
1.4.1
Deployment Method
Amplify CLI
Schema
The text was updated successfully, but these errors were encountered: