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

DataStore Sync Issue: Sometimes, DataStore saves data locally when the network is available. #13833

Open
3 tasks done
vijaykishan312 opened this issue Sep 19, 2024 · 1 comment
Assignees
Labels
DataStore Related to DataStore category pending-community-response Issue is pending a response from the author or community. React Native React Native related issue V5

Comments

@vijaykishan312
Copy link

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

DataStore

Amplify Version

v5

Amplify Categories

storage, api

Backend

Amplify CLI

Environment information

# Put output below this line
**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:**

- @aws-amplify/datastore-storage-adapter: ^1.4.5
- aws-amplify: ^5.3.10 
- react-native:0.68.2


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:

  • @aws-amplify/datastore-storage-adapter: ^1.4.5
  • aws-amplify: ^5.3.10
  • react-native:0.68.2

Expected behavior

All data is also synchronised via the datastore

Reproduction steps

  1. Create data with DataStore and AWS GraphQL
  2. Check the code logs
  3. Check the data in DynamoDB, but note that there might be some issues or additional information to review

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

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

iPhone 15, Pixel 5A

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending a response from the Amplify team. labels Sep 19, 2024
@cwomack cwomack added DataStore Related to DataStore category React Native React Native related issue V5 labels Sep 19, 2024
@chrisbonifacio chrisbonifacio removed the pending-triage Issue is pending triage label Oct 3, 2024
@chrisbonifacio
Copy link
Member

chrisbonifacio commented Oct 3, 2024

Hi @vijaykishan312 👋 thanks for raising this issue. I see that you are still using v5 of the aws-amplify library. Is there any reason you are not able to upgrade to v6?

If you have tried to upgrade, do you experience this issue on v6 or the latest version of aws-amplify as well?

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending a response from the Amplify team. label Oct 3, 2024
@chrisbonifacio chrisbonifacio self-assigned this Oct 3, 2024
@chrisbonifacio chrisbonifacio added the pending-community-response Issue is pending a response from the author or community. label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DataStore Related to DataStore category pending-community-response Issue is pending a response from the author or community. React Native React Native related issue V5
Projects
None yet
Development

No branches or pull requests

3 participants