amplify-js: DataStore queries don't do anything on the first load of the application
Describe 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.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (5 by maintainers)
Commits related to this issue
- fix(@aws-amplify/datastore): RN - fix queries don't do anything on the first load of the application Fixes #5991 — committed to manueliglesias/aws-amplify by manueliglesias 4 years ago
- fix(@aws-amplify/datastore): RN - fix queries don't do anything on the first load of the application (#6010) Fixes #5991 — committed to aws-amplify/amplify-js by manueliglesias 4 years ago
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:
@manueliglesias Nevermind I figured out I can listen to the outboxStatus event:
outboxStatus {"isEmpty": false}