DataStore Sync Issue: Sometimes, DataStore saves data locally when the network is available. #13832
Closed
3 tasks done
Labels
duplicate
If marked with duplicate, issue will be closed & original will be added for traceability
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
DataStore
Amplify Version
v5
Amplify Categories
storage, api
Backend
Amplify CLI
Environment information
Describe the bug
Issue: AWS Amplify DataStore Sync Problem
Description: The AWS Amplify DataStore is not functioning correctly when data is inserted using DataStore.save(). Occasionally, the data does not sync with the server and remains only in the local storage (DynamoDB). After some time, the data eventually syncs with the server.
Library Versions:
Expected behavior
All data is also synchronised via the datastore
Reproduction steps
Code Snippet
// Put your code below this line.
const dataCollection = {
sessionDuration: dataResponse[0]?.sessionDuration,
collectionStorage: dataResponse[0]?.collectionStorage,
currentStorageLocation: privousCollectionData[0]
?.previousCurrentStorageLocation
? privousCollectionData[0]?.previousCurrentStorageLocation
: dataResponse[0]?.currentStorageLocation,
CollectionUsedDate: null,
isCollectionUsed: false,
storeReferenceId: privousCollectionData[0]?.previousStoreReferenceId,
collectionUsedBy: '',
otherUsedMessage: null,
isActivityFinish: true,
collectionId: null,
id: privousCollectionData[i]?.id,
locationChangeDate:
privousCollectionData[0]?.previousLocationChangeDate,
storageExpiryAlert:
privousCollectionData[0]?.previousStorageExpiryAlert,
storageExpiry: privousCollectionData[0]?.previousStorageExpiry,
updatedAt: currentUTCTime(),
activityType: 'Collection',
activitySide: dataResponse[0]?.activitySide,
activityEndTime: privousCollectionData[0]?.previousActivityEndTime,
sessionEndTime: privousCollectionData[0]?.previousSessionEndTime,
previousStoreReferenceId: '',
previousStorageExpiryAlert: '',
previousLocationChangeDate: '',
previousCurrentStorageLocation:
privousCollectionData[0]?.previousCurrentStorageLocation,
previousStorageExpiry: '',
previousActivityEndTime: '',
previousSessionEndTime: '',
subjectId: '',
stashTotalFeed: '',
activityDoneVia: dataResponse[0]?.activityDoneVia,
activityDuration:dataResponse[0]?.activityDuration,
sessionStartTime:dataResponse[0]?.sessionStartTime,
subjectAvatarName:dataResponse[0]?.subjectAvatarName,
activityStartTime:dataResponse[0]?.activityStartTime,
unitOfMeasurement:dataResponse[0]?.unitOfMeasurement,
appId:dataResponse[0]?.appId,
_deleted:dataResponse[0]?._deleted,
preStorageLocation:dataResponse[0]?.preStorageLocation,
stashUsedCollectionId:dataResponse[0]?.stashUsedCollectionId,
stashStart:dataResponse[0]?.stashStart,
vijay:dataResponse[0]?.vijay,
createdAt:dataResponse[0]?.createdAt,
deviceType:dataResponse[0]?.deviceType,
_lastChangedAt:dataResponse[0]?._lastChangedAt,
isSync:dataResponse[0]?.isSync,
owner:dataResponse[0]?.owner,
collectionStorageUsed:String(dataResponse[0]?.collectionStorageUsed),
sessionId:dataResponse[0]?.sessionId,
};
// Code for data save
const response = await DataStore.save(new Activity(dataCollection))
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
iPhone 15
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: