aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.33k stars 247 forks source link

Not getting any events from DataStore #2127

Closed skim037 closed 2 years ago

skim037 commented 2 years ago

Description

I started seeing this issue suddenly. There is no changes to my app or schema.

When my app starts, it listens to datastore event like this.

void waitForDataStore() async {
    await Amplify.DataStore.stop();
    await Amplify.DataStore.clear();

    await Future.delayed(const Duration(seconds: 1));
    await Amplify.DataStore.start();

    try {
      // Execute dummy query. (https://github.com/aws-amplify/amplify-flutter/issues/865)
      await profileRepo.getProfile(userId: user.userId);
    } on NoProfileExistsException {
      // Ignore
    } 

    StreamSubscription dsHub =
      Amplify.Hub.listen([HubChannel.DataStore], (hubEvent) {
    });
    dsHub.onData((data) async {
      if (data.eventName == 'ready') {
        await getProfile();
        await dsHub.cancel();
      } 
    });
  }

For some reason, datastore is not sending any events. I have not made any changes as far as I'm aware. No code changes, no recent upgrades, no schema changes. I was wondering if there is something going on from datastore side.

Thanks.

Categories

Steps to Reproduce

No response

Screenshots

No response

Platforms

Android Device/Emulator API Level

No response

Environment

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-arm, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.71.0)
[✓] Connected device (4 available)
[✓] HTTP Host Availability

Dependencies

Dart SDK 2.17.6
Flutter SDK 3.0.5
cuppacoffee 1.0.0+1

dependencies:
- amplify_api 0.5.1 [amplify_api_plugin_interface amplify_core amplify_api_android amplify_api_ios collection flutter meta plugin_platform_interface]
- amplify_auth_cognito 0.5.1 [amplify_auth_cognito_android amplify_auth_cognito_ios amplify_auth_plugin_interface amplify_core collection flutter plugin_platform_interface]
- amplify_authenticator 0.1.2 [amplify_auth_cognito amplify_auth_plugin_interface amplify_core amplify_flutter collection flutter flutter_localizations intl]
- amplify_datastore 0.5.1 [flutter amplify_datastore_plugin_interface amplify_core plugin_platform_interface meta collection async]
- amplify_datastore_plugin_interface 0.5.1 [flutter meta collection amplify_core]
- amplify_flutter 0.5.1 [amplify_analytics_plugin_interface amplify_api_plugin_interface amplify_auth_plugin_interface amplify_core amplify_datastore_plugin_interface amplify_flutter_android amplify_flutter_ios amplify_storage_plugin_interface collection flutter json_annotation meta plugin_platform_interface]
- amplify_storage_s3 0.5.1 [flutter amplify_storage_plugin_interface plugin_platform_interface amplify_storage_s3_android amplify_storage_s3_ios amplify_core]
- cached_network_image 3.2.1 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web]
- checkbox_formfield 0.2.0 [flutter]
- cron 0.5.0 [clock]
- cupertino_icons 1.0.5
- dotted_border 2.0.0+2 [flutter path_drawing]
- dropdown_button2 1.6.3 [flutter]
- email_validator 2.0.1
- firebase_core 1.21.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_messaging 12.0.3 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_app_badger 1.4.0 [flutter]
- flutter_bloc 8.0.1 [flutter bloc provider]
- flutter_feather_icons 2.0.0+1 [flutter]
- flutter_google_places 0.3.0 [flutter google_api_headers google_maps_webservice http rxdart]
- flutter_image_compress 1.1.0 [flutter]
- flutter_local_notifications 9.8.0+1 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone]
- flutter_slidable 2.0.0 [flutter]
- flutterfire_cli 0.2.4 [ansi_styles args ci cli_util deep_pick file interact meta path platform pub_updater pubspec xml]
- geocoder2 1.3.0 [flutter http]
- geocoding 2.0.4 [flutter geocoding_platform_interface]
- geolocator 9.0.1 [flutter geolocator_platform_interface geolocator_android geolocator_apple geolocator_web geolocator_windows]
- google_maps_flutter 2.2.0 [flutter google_maps_flutter_android google_maps_flutter_ios google_maps_flutter_platform_interface]
- google_maps_webservice 0.0.20-nullsafety.5 [http meta json_annotation]
- google_mobile_ads 2.0.1 [meta flutter visibility_detector]
- google_place 0.4.7 [http]
- image_picker 0.8.5+3 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_platform_interface]
- intl 0.17.0 [clock path]
- material_design_icons_flutter 5.0.6595 [flutter]
- path_provider 2.0.11 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows]
- percent_indicator 4.2.2 [flutter]
- permission_handler 10.0.0 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface]
- provider 6.0.3 [collection flutter nested]
- quiver 3.1.0 [matcher]

transitive dependencies:
- amplify_analytics_plugin_interface 0.5.1 [amplify_core flutter meta]
- amplify_api_android 0.5.1 [flutter]
- amplify_api_ios 0.5.1 [amplify_core flutter]
- amplify_api_plugin_interface 0.5.1 [amplify_core collection flutter json_annotation meta]
- amplify_auth_cognito_android 0.5.1 [flutter]
- amplify_auth_cognito_ios 0.5.1 [amplify_core flutter]
- amplify_auth_plugin_interface 0.5.1 [amplify_core flutter meta]
- amplify_core 0.5.1 [collection date_time_format flutter meta plugin_platform_interface uuid]
- amplify_flutter_android 0.5.1 [flutter]
- amplify_flutter_ios 0.5.1 [amplify_core flutter]
- amplify_storage_plugin_interface 0.5.1 [flutter meta amplify_core]
- amplify_storage_s3_android 0.5.1 [flutter]
- amplify_storage_s3_ios 0.5.1 [flutter]
- ansi_styles 0.3.2+1
- args 2.3.1
- async 2.8.2 [collection meta]
- bloc 8.0.3 [meta]
- boolean_selector 2.1.0 [source_span string_scanner]
- cached_network_image_platform_interface 1.0.0 [flutter flutter_cache_manager]
- cached_network_image_web 1.0.1 [flutter flutter_cache_manager cached_network_image_platform_interface]
- characters 1.2.0
- charcode 1.3.1
- ci 0.1.0
- cli_util 0.3.5 [meta path]
- clock 1.1.0
- collection 1.16.0
- cross_file 0.3.3+1 [js meta]
- crypto 3.0.2 [typed_data]
- dart_console 1.1.1 [ffi win32 intl]
- date_time_format 2.0.1
- dbus 0.7.3 [args ffi meta xml]
- deep_pick 0.10.0
- fake_async 1.3.0 [clock collection]
- ffi 1.2.1
- file 6.1.2 [meta path]
- firebase_core_platform_interface 4.5.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 1.7.1 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_messaging_platform_interface 4.1.2 [firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 3.1.2 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta]
- flutter_blurhash 0.7.0 [flutter]
- flutter_cache_manager 3.3.0 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid]
- flutter_local_notifications_linux 0.5.1 [flutter flutter_local_notifications_platform_interface dbus path xdg_directories]
- flutter_local_notifications_platform_interface 5.0.0 [flutter plugin_platform_interface]
- flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math]
- flutter_plugin_android_lifecycle 2.0.6 [flutter]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- geocoding_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- geolocator_android 4.0.2 [flutter geolocator_platform_interface]
- geolocator_apple 2.2.1 [flutter geolocator_platform_interface]
- geolocator_platform_interface 4.0.6 [flutter plugin_platform_interface vector_math meta]
- geolocator_web 2.1.6 [flutter flutter_web_plugins geolocator_platform_interface]
- geolocator_windows 0.1.1 [flutter geolocator_platform_interface]
- google_api_headers 1.3.0 [flutter package_info_plus]
- google_maps_flutter_android 2.3.0 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface stream_transform]
- google_maps_flutter_ios 2.1.11 [flutter google_maps_flutter_platform_interface stream_transform]
- google_maps_flutter_platform_interface 2.2.2 [collection flutter plugin_platform_interface stream_transform]
- http 0.13.4 [async http_parser meta path]
- http_parser 4.0.1 [collection source_span string_scanner typed_data]
- image_picker_android 0.8.5+1 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- image_picker_for_web 2.1.8 [flutter flutter_web_plugins image_picker_platform_interface]
- image_picker_ios 0.8.5+6 [flutter image_picker_platform_interface]
- image_picker_platform_interface 2.5.0 [cross_file flutter http plugin_platform_interface]
- interact 2.1.1 [dart_console meta tint]
- js 0.6.4
- json_annotation 4.5.0 [meta]
- matcher 0.12.11 [stack_trace]
- material_color_utilities 0.1.4
- meta 1.7.0
- nested 1.0.0 [flutter]
- octo_image 1.0.2 [flutter flutter_blurhash]
- package_info_plus 1.4.2 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web]
- package_info_plus_linux 1.0.5 [package_info_plus_platform_interface flutter path]
- package_info_plus_macos 1.3.0 [flutter]
- package_info_plus_platform_interface 1.0.2 [flutter meta plugin_platform_interface]
- package_info_plus_web 1.0.5 [flutter flutter_web_plugins http meta package_info_plus_platform_interface]
- package_info_plus_windows 1.0.5 [package_info_plus_platform_interface ffi flutter win32]
- path 1.8.1
- path_drawing 1.0.1 [vector_math meta path_parsing flutter]
- path_parsing 1.0.1 [vector_math meta]
- path_provider_android 2.0.16 [flutter path_provider_platform_interface]
- path_provider_ios 2.0.10 [flutter path_provider_platform_interface]
- path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_macos 2.0.6 [flutter path_provider_platform_interface]
- path_provider_platform_interface 2.0.4 [flutter platform plugin_platform_interface]
- path_provider_windows 2.0.7 [ffi flutter path path_provider_platform_interface win32]
- pedantic 1.11.1
- permission_handler_android 10.0.0 [flutter permission_handler_platform_interface]
- permission_handler_apple 9.0.4 [flutter permission_handler_platform_interface]
- permission_handler_platform_interface 3.7.0 [flutter meta plugin_platform_interface]
- permission_handler_windows 0.1.0 [flutter permission_handler_platform_interface]
- petitparser 5.0.0 [meta]
- platform 3.1.0
- plugin_platform_interface 2.1.2 [meta]
- process 4.2.4 [file path platform]
- pub_semver 2.1.1 [collection meta]
- pub_updater 0.2.2 [http json_annotation process]
- pubspec 2.3.0 [path pub_semver yaml uri]
- rxdart 0.26.0
- sky_engine 0.0.99
- source_span 1.8.2 [collection path term_glyph]
- sqflite 2.0.3 [flutter sqflite_common path]
- sqflite_common 2.2.1+1 [synchronized path meta]
- stack_trace 1.10.0 [path]
- stream_channel 2.1.0 [async]
- stream_transform 2.0.0
- string_scanner 1.1.0 [charcode source_span]
- synchronized 3.0.0+2
- term_glyph 1.2.0
- test_api 0.4.9 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher]
- timezone 0.8.0 [path]
- tint 2.0.0
- typed_data 1.3.0 [collection]
- uri 1.0.0 [matcher quiver]
- uuid 3.0.6 [crypto]
- vector_math 2.1.2
- visibility_detector 0.3.3 [flutter]
- win32 2.6.1 [ffi]
- xdg_directories 0.2.0+1 [meta path process]
- xml 5.4.1 [collection meta petitparser]
- yaml 3.1.1 [collection source_span string_scanner]

Device

iPhone 12

OS

iOS

Deployment Method

Amplify CLI

CLI Version

10.0.0

Additional Context

No response

Amplify Config

?

skim037 commented 2 years ago

I think I found the issue. I noticed that there were a lot of data accumulated over time while I was testing. It could be that the sync operation took long time and eventually timed out? After deleting the record, the app starts working again.

Before resolving the issue, is there a way to debug this more efficiently? Where can I get logs to investigate issues related to datastore?

Thanks.

dnys1 commented 2 years ago

Hi @skim037 - sorry you are facing this issue. On iOS, DataStore logs can be viewed most easily by running the app through Xcode. Can you try that and let me know if DataStore was indeed timing out or if there are other issues going on?

skim037 commented 2 years ago

@dnys1 Thanks for the information!. I will give it a try next time I run into Datastore issues. Please feel free to close this issue.

Thanks

dnys1 commented 2 years ago

Sounds good, thanks @skim037. And please feel free to create another if you run into any more issues.