DataStore queries don't do anything on the first load of the application
See original GitHub issueDescribe the bug After newest update, DataStore queries don’t do anything on the first load of the react-native application. Only on the second load, it starts to work properly.
To Reproduce Steps to reproduce the behavior:
- Open react-native application
- Sign in with a user
- Try to get some data with DataStore.query(Something)
- Don’t get anything (well it spits empty arrays, so I don’t think that it does anything good)
- Close application.
- Open application again
- Now everything works
Expected behavior Expecting some data on the first load, as it worked before.
Code Snippet Standard DataStore.query(SomeDataToQuery)
What is Configured?
It worked on this version:
"@aws-amplify/api": "3.1.12",
"@aws-amplify/auth": "3.2.9",
"@aws-amplify/cache": "3.1.12",
"@aws-amplify/core": "3.2.9",
"@aws-amplify/datastore": "2.1.2",
"@aws-amplify/pubsub": "3.0.13",
"@aws-amplify/storage": "3.2.2",
Now it doesn’t:
"@aws-amplify/api": "3.1.14-unstable.2",
"@aws-amplify/auth": "3.2.11-unstable.2",
"@aws-amplify/cache": "3.1.14-unstable.2",
"@aws-amplify/core": "3.3.1-unstable.2",
"@aws-amplify/datastore": "2.2.1-unstable.2",
"@aws-amplify/pubsub": "3.0.15-unstable.2",
"@aws-amplify/storage": "3.2.4-unstable.2",
Additional context Few other guys are getting the same issue, you can find more on discord channel for amplify-js. Running a react-native application.
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (5 by maintainers)
Top Results From Across the Web
AWS Datastore doesnt query when app oppens for the first time
To resolve your issue, try using DataStore.start at the beginning of app startup and then monitor the Amplify hub for the Datastore ready...
Read more >Datastore Queries - App Engine standard environment
Queries execute as read-only. This page describes the structure and kinds of queries used within App Engine to retrieve data from Cloud Datastore....
Read more >Amplify DataStore best practices - AWS Documentation
Clear offline data on sign-in and sign-out. We recommend that you clear out user-specific data for shared device scenarios. This prevents security and ......
Read more >querying for entites returns empty list - Google Groups
This sounds like a cache contamination issue - especially the 30m delay (long enough for cache eviction). Perhaps you have those negative cache...
Read more >Entity Groups, Ancestors, and Indexes in Datastore- A Working ...
With more complicated queries, Datastore requires specific indexes to be set in place. For example, running the same query with an additional ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @Darapsas and @nubpro
When enabling syncing to the cloud on the DataStore, queries you run might yield empty or incomplete results if the initial sync process hasn’t completed or there is not enough data synced locally at the time of the query. In this scenario, you can either wait for the sync process to finish (by listening to the
'ready'
event on the'datastore'
Hub channel) or you can observe a model until you accumulate enough data to render your UI.Below you’ll find these two approaches exemplified:
Waiting for the sync process to finish
Observing a Model until enough data is available
@mdoesburg The publish to npm just finished, try again, these are the versions: