aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.44k stars 2.13k forks source link

Real time sync does not work between members of the group - It syncs up fine eventually within hours #8396

Open droidgeek1 opened 3 years ago

droidgeek1 commented 3 years ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication, DataStore

Amplify Categories

auth, function, api

Environment information

``` # Put output below this line System: OS: macOS Mojave 10.14.6 CPU: (8) x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz Memory: 306.86 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.18.1 - ~/.nvm/versions/node/v12.18.1/bin/node npm: 6.14.5 - ~/.nvm/versions/node/v12.18.1/bin/npm Browsers: Chrome: 91.0.4472.77 Firefox: 89.0 Safari: 14.0 npmPackages: @babel/core: ~7.14.2 => 7.14.3 (7.9.0) @material-ui/core: ^4.11.4 => 4.11.4 @material-ui/icons: ^4.11.2 => 4.11.2 @react-native-async-storage/async-storage: ^1.13.0 => 1.15.4 @react-native-community/datetimepicker: 3.2.0 => 3.2.0 @react-native-community/eslint-config: 1.1.0 @react-native-community/eslint-plugin: 1.0.0 @react-native-community/masked-view: 0.1.10 => 0.1.10 @react-native-community/netinfo: 6.0.0 => 6.0.0 @react-navigation/drawer: ^5.12.5 => 5.12.5 @react-navigation/native: ^5.9.4 => 5.9.4 @react-navigation/stack: ^5.14.5 => 5.14.5 @types/react-datepicker: ^3.1.8 => 3.1.8 @types/react-native-autocomplete-input: ^4.0.1 => 4.0.1 @typescript-eslint/eslint-plugin: ^4.19.0 => 4.25.0 @typescript-eslint/parser: ^4.19.0 => 4.25.0 HelloWorld: 0.0.1 aws-amplify: ^4.0.3 => 4.0.3 aws-amplify-react-native: ^5.0.0 => 5.0.1 babel-plugin-inline-view-configs: 0.0.5 eslint: ^7.23.0 => 7.27.0 eslint-config-airbnb: ^18.2.1 => 18.2.1 eslint-plugin-import: ^2.22.1 => 2.23.4 eslint-plugin-jsx-a11y: ^6.4.1 => 6.4.1 eslint-plugin-react: ^7.23.1 => 7.24.0 eslint-plugin-react-hooks: ^4.2.0 => 4.2.0 expo: ^41.0.0 => 41.0.1 expo-app-loading: ^1.0.1 => 1.0.3 expo-linking: ^2.2.3 => 2.2.3 expo-mail-composer: ~10.1.2 => 10.1.2 expo-sms: ~9.1.2 => 9.1.2 expo-status-bar: ~1.0.4 => 1.0.4 hermes-inspector-msggen: 1.0.0 ini: ^2.0.0 => 2.0.0 inquirer: ^8.0.0 => 8.1.0 (3.3.0) react: 17.0.2 => 17.0.2 react-animated: 0.1.0 react-datepicker: ^3.7.0 => 3.8.0 react-dom: 17.0.2 => 17.0.2 react-native: https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz => 0.63.2 react-native-autocomplete-input: ^5.0.0 => 5.0.0 react-native-bundle-visualizer: ^2.2.1 => 2.2.1 react-native-codegen: 0.0.2 react-native-elements: ^3.4.1 => 3.4.1 react-native-gesture-handler: ~1.10.2 => 1.10.3 react-native-reanimated: ~2.1.0 => 2.1.0 react-native-safe-area-context: 3.2.0 => 3.2.0 react-native-screens: ~3.0.0 => 3.0.0 react-native-touchable-scale: ^2.1.2 => 2.1.2 react-native-web: ^0.16.3 => 0.16.3 typescript: ~4.2.4 => 4.2.4 webpack-bundle-analyzer: ^4.4.2 => 4.4.2 webpack-cli: ^4.7.0 => 4.7.0 npmGlobalPackages: @aws-amplify/cli: 4.51.4 amplify-cli-core: 1.3.4 expo-cli: 4.4.7 npm: 6.14.5 webpack: 5.37.1 ```

Describe the bug

Using Datastore with auth rules of owner and group. GroupField is one of the fields on the entity. Expo Web App inserts/updates data from two different browsers with two different logins using Cognito auth. I have subscribed for updates. I get updates after few hours but not in real time. If I refresh the App or reload the App, then I get updates right-away. I see Observe method called whenever updates happen. Problem is it is not getting called in REAL time. WHat could I be missing ? Again, if I reload the browser, I get updates made right-away. Also underlying DynamoDB is updated instantly. I can see that but that data is not pushed to the other client who did not make a change but is 'observing'. I have two observers just to be sure, one gets registered after DataStore is 'READY' and one immediately in useEffect after DataStore.start(). Most of the time it's the later one that get's fired after few hours as seen from the chrome/safari console.

type SampleEntity @model @auth(rules: [{ allow: owner }, { allow: groups, groupsField: "sampleGroupField" }]) { id: ID! sampleGroupField: ID! owner: String firstName: String }

Expected behavior

Expecing both chrome and safari logged users to get data in realtime instead of delayed

Reproduction steps

Create the entity as I shown above and insert data from two different client/browsers. Datastore does not fire real-time updates

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

droidgeek1 commented 3 years ago

Chrome/Safari prints following every minute. Not sure if its related but Observer is null ..

[DEBUG] 12:26.788 AWSAppSyncRealTimeProvider {id: "", observer: null, query: "", variables: {…}}id: ""observer: nullquery: ""variables: {}proto: Object ConsoleLogger.js:97

droidgeek1 commented 3 years ago

Also just to be clear, the real time sync works perfectly fine when SAME user is signed in from both browsers. So this points and confirms that something with Group Members that is not doing real time sync

droidgeek1 commented 3 years ago

Bottomline - real time sync works for same owner but not for different owners in the same group. Is this a bug or pending feature? Could I be doing something wrong? Appreciate help from the experts. It works eventually and I am not sure what determines the timeline of this eventual sync. Is it configurable?

droidgeek1 commented 3 years ago

@iartemiev Thanks for adding to DataStore tag. Do we have an update on this - at least to tell me if I should expect REAL TIME update to mulitple users in a group when group is defined by one of the columns of the Entity in graphQL schema? This would be a show stopper if there is no way to have real time sync across users in the group.

droidgeek1 commented 3 years ago

@iartemiev Following up again - Just need Yes or No responses at this time to the following question so I can decide. I understand you gus are busy building amazing product so I am now asking for a Y or N answer at this time. If you could direct me to right person that would be great to too. Is it possible to get near REAL TIME ( 10 seconds) update to multiple users in a group when group is defined by one of the columns of the Model in graphQL schema?