-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 operations fails after internet fluctuations #13035
Comments
Hi @Akash-T2S! I have a few follow-up questions to help us better understand the issue:
Thank you! |
@david-mcafee Thanks for these steps, Step 1 - has been followed thoroughly and implemented in the same way. DS Configure: const configureDataStore = () => {
DataStore.configure({
authProviders: {
functionAuthProvider: async () => {
return {
token: licenseKey
};
}
},
syncExpressions: getSyncExpression(storeId, settingsTimeZone),
syncPageSize: 1000,
maxRecordsToSync: 100000,
fullSyncInterval: FULL_SYNC_INTERVAL,
storageAdapter: SQLiteAdapter,
errorHandler: (error) => {}
});
} DS Life cycle: const clearDataStore = async () => {
await DataStore.clear();
};
const stopDataStore = async () => {
await DataStore.stop();
};
const startDataStore = async () => {
await DataStore.start();
}; DS Initialisation: useEffect(() => {
configureDataStore();
startDataStore();
if (!hubListener) {
hubListener = Hub.listen('datastore', async (hubData) => {
if (event === 'ready') {
const order = await DataStore.query(Order, (c) =>
c.and((c) => [
c.storeId.eq(storeId),
c.deliveryAt.ge(getGraterThanDatesForSyncExpression(settingsTimeZone))
])
);
}
}
}
return () => {
removeOrderSubscription();
removePrinterObjSubscription();
if (isValidElement(hubListener)) {
hubListener();
hubListener = null;
}
if (isValidElement(pubsubListner)) {
pubsubListner();
pubsubListner = null;
}
};
}, []); |
@Akash-T2S, can you share any relevant code where you're calling |
@cwomack clearDataStore will be called only on logout. Whereas stopDataStore will be called when there is any KeepAliveTimeOut happens (KA acknowledgement is missed) through 'api' channel.
|
@Akash-T2S - it looks like the failure is occurring when you attempt to perform a DataStore operation (e.g. Additionally, since DataStore works offline, there shouldn't be a need to stop / start DataStore on connection state changes. Can you help us understand your usecase for stopping / starting DataStore on connection state changes? Lastly, have you attempted to upgrade to the versions listed in this comment? |
@david-mcafee I agree with your point, I make query’s and other operations only when AppSync ready event trigger(after all model synced). Also, I'm trying to stop and start only when the pending keep alive is missed and not when the transition of network status. Even when I don't have that block of code the same issue happens. This reproducible steps are tricky but tbh it occurs more often in the latest version. Regarding the version update, No luck on that. |
@Akash-T2S - thank you for your response! To confirm, are you saying that the issue is still present even when you completely disable all calls to Lastly, you mentioned that you had no luck on updating the Amplify version - can you help us understand the issue so we can assist with unblocking you? Thank you!! |
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
DataStore
Amplify Version
v5
Amplify Categories
No response
Backend
None
Environment information
Describe the bug
I have been using Amplify Datastore for the past 2 years and after the update to version 5.x.x I've encountered an issue with intermittent internet connectivity. Whenever there are fluctuations in the network, the networkStatus of the HubListener first reports false and then true. After a full or delta sync, any Datastore action fails and throws errors, rendering Datastore unusable until I refresh the app.
The issue is depend on the next action after the internet fluctuations.
Issue: DataStoreStateError: Tried to execute
DataStore.query()/DataStore.Start()
while DataStore was "Stopping".This can only be done while DataStore is "Started" or "Stopped". To remedy:
Ensure all calls to
stop()
andclear()
have completed first.If this is not possible, retry the operation until it succeeds
Once internet is back usual delta sync too fails at times. This can be reproduced in both Android & iOS devices
Expected behavior
Datastore operations should perform even after internet fluctuations and should not affect the usage of it.
Reproduction steps
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: