You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I update a model record locally in the app and then I reload(in development) or close and open the app(in release) the app, the datastore returns an older version of the record and then updates to the latest version.
Expected behavior
The expected behavior is that when I reload the app or open it from a closed state the record version I should receive immediately should be at least the same version that I had before I did the reload/closed the app since the records are persisted.
Reproduction steps
Initialize a new amplify with default datastore project following the guide
paste the following in your App.tsx:
import'@azure/core-asynciterator-polyfill';import{DataStore}from'aws-amplify/datastore';import{Button,View}from'react-native';import{Todo}from'./src/models';import{useEffect}from'react';import{Amplify}from'aws-amplify';importamplifyconfigfrom'./src/amplifyconfiguration.json';import{ConsoleLogger}from'aws-amplify/utils';Amplify.configure(amplifyconfig);ConsoleLogger.LOG_LEVEL='WARN';functionApp(){useEffect(()=>{DataStore.observeQuery(Todo).subscribe(snaptshot=>{consttodo=snaptshot.items[0];console.log("todo's name from observe:",todo.name);});},[]);return(<Viewstyle={{flex: 1,backgroundColor: 'white',justifyContent: 'center',alignItems: 'center',}}><Buttontitle="create post"onPress={async()=>{awaitDataStore.save(newTodo({name: '1',description: 'desc',}),);}}/><Buttontitle="update post"onPress={async()=>{lettodo=(awaitDataStore.query(Todo))[0];console.log("todo's name before update:",todo.name);awaitDataStore.save(Todo.copyOf(todo,updated=>{updated.name=String(Number(updated.name)+1);}),);todo=(awaitDataStore.query(Todo))[0];console.log("todo's name after update:",todo.name);}}/></View>);}exportdefaultApp;
create a record by pressing create record
update the record
reload the app
notice how the observeQuery first returns an old todo name and then correct todo name
Check here the screen recording:
Screen.Recording.2024-04-19.at.10.22.20.AM.mov
Notice that every time I reload the app I get a version older but in the last one I got a way old version
The text was updated successfully, but these errors were encountered:
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
DataStore
Amplify Version
v6
Amplify Categories
No response
Backend
Amplify CLI
Environment information
Describe the bug
When I update a model record locally in the app and then I reload(in development) or close and open the app(in release) the app, the datastore returns an older version of the record and then updates to the latest version.
Expected behavior
The expected behavior is that when I reload the app or open it from a closed state the record version I should receive immediately should be at least the same version that I had before I did the reload/closed the app since the records are persisted.
Reproduction steps
Check here the screen recording:
Screen.Recording.2024-04-19.at.10.22.20.AM.mov
Notice that every time I reload the app I get a version older but in the last one I got a way old version
The text was updated successfully, but these errors were encountered: