firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.67k stars 3.97k forks source link

[remote_config] internal remote config fetch error #6196

Closed rubenvereecken closed 1 year ago

rubenvereecken commented 3 years ago

Bug report

Describe the bug Before we upgraded, I've never had this not happen to me. Strangely, my colleague never gets this on his device. Firebase throws every single time we call fetchAndActivate().

Here's the whole stacktrace

Task <C134C25B-109D-43EF-8FC5-CC663AB1CBD7>.<1> finished with error [-999] Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://firebaseremoteconfig.googleapis.com/v1/projects/lessgo-dev/namespaces/firebase:fetch?key=AIzaSyAVEBJyZXrLWDTAHK5j092NMesJ-v1K9FY, NSLocalizedDescription=cancelled, NSErrorFailingURLKey=https://firebaseremoteconfig.googleapis.com/v1/projects/lessgo-dev/namespaces/firebase:fetch?key=AIzaSyAVEBJyZXrLWDTAHK5j092NMesJ-v1K9FY}
7.11.0 - [Firebase/RemoteConfig][I-RCN000026] RCN Fetch failure: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://firebaseremoteconfig.googleapis.com/v1/projects/lessgo-dev/namespaces/firebase:fetch?key=AIzaSyAVEBJyZXrLWDTAHK5j092NMesJ-v1K9FY, NSLocalizedDescription=cancelled, NSErrorFailingURLKey=https://firebaseremoteconfig.googleapis.com/v1/projects/lessgo-dev/namespaces/firebase:fetch?key=AIzaSyAVEBJyZXrLWDTAHK5j092NMesJ-v1K9FY}. No cached config result.
7.11.0 - [Firebase/RemoteConfig][I-RCN000026] RCN Fetch failure. Response http error code: 0
Task <C134C25B-109D-43EF-8FC5-CC663AB1CBD7>.<1> HTTP load failed, 0/0 bytes (error code: -999 [1:89])
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ [firebase_remote_config/internal] internal remote config fetch error
flutter: │
flutter: │ #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:581:7)
flutter: │ #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18)
flutter: │ <asynchronous suspension>
flutter: │ #2      MethodChannelFirebaseRemoteConfig.fetchAndActivate (package:firebase_remote_config_platform_interface/src/method_channel/method_channel_firebase_remote_config.dart:145:29)
flutter: │ <asynchronous suspension>
flutter: │ #3      RemoteConfig.fetchAndActivate (package:firebase_remote_config/src/remote_config.dart:86:26)
flutter: │ <asynchronous suspension>
flutter: │ #4      RemoteConfigRepository._fetchRemoteConfig (package:woushe_refactored/src/repositories/remote_config_repository.dart:48:7)
flutter: │ <asynchronous suspension>
flutter: │
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ #0   MethodChannelFirebaseRemoteConfig.fetchAndActivate (package:firebase_remote_config_platform_interface/src/method_channel/method_channel_firebase_remote_config.dart:155:7)
flutter: │ #1   <asynchronous suspension>
flutter: │ #2   RemoteConfig.fetchAndActivate (package:firebase_remote_config/src/remote_config.dart:86:26)
flutter: │ #3   <asynchronous suspension>
flutter: │ #4   RemoteConfigRepository._fetchRemoteConfig (package:woushe_refactored/src/repositories/remote_config_repository.dart:48:7)
flutter: │ #5   <asynchronous suspension>
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 12:51:54.482 (+0:00:00.502445)

Steps to reproduce

final remoteConfig = RemoteConfig.instance;
await remoteConfig.setConfigSettings(RemoteConfigSettings(
  fetchTimeout: const Duration(seconds: 20),
  minimumFetchInterval: const Duration(minutes: 20),
));
await remoteConfig.fetchAndActivate(); // This bad boy throws

Additional context

This only started happening after we upgraded to Flutter 2 and adopted new Firebase package versions.

Flutter doctor

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.0.6, on Mac OS X 10.15.7 19H524 darwin-x64, locale en-GB) [!] Android toolchain - develop for Android devices (Android SDK version 30.0.2) ✗ Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [✓] Android Studio (version 4.0) [✓] VS Code (version 1.55.2) [✓] Connected device (2 available) ! Doctor found issues in 1 category. ```

Flutter dependencies

Click To Expand ``` Dart SDK 2.12.3 Flutter SDK 2.0.6 woushe_refactored 1.0.42+118 dependencies: - add_2_calendar 2.1.0 [flutter] - auto_size_text 3.0.0-nullsafety.0 [flutter] - cached_network_image 3.0.0 [flutter flutter_cache_manager octo_image] - chewie 1.0.0 [cupertino_icons flutter video_player wakelock] - circular_check_box 1.0.4 [flutter] - collection 1.15.0 - confetti 0.6.0-nullsafety [flutter random_color vector_math] - contacts_service 0.6.1 [flutter collection quiver] - cupertino_icons 1.0.3 - date_time_format 2.0.1 - device_info 2.0.0 [flutter device_info_platform_interface] - devicelocale 0.4.1 [flutter flutter_web_plugins] - dio 4.0.0 [http_parser path] - equatable 2.0.0 [collection meta] - firebase_analytics 8.0.4 [firebase_analytics_platform_interface firebase_analytics_web firebase_core flutter meta] - firebase_auth 1.1.4 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 1.1.1 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 2.0.3 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_dynamic_links 2.0.3 [firebase_core flutter] - firebase_messaging 9.1.4 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_remote_config 0.10.0-dev.3 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_datetime_picker 1.5.1 [flutter] - flutter_image_compress 1.0.0 [flutter] - flutter_libphonenumber 1.0.3 [flutter] - flutter_linkify 5.0.2 [flutter linkify] - flutter_markdown 0.6.1 [flutter markdown meta path] - flutter_native_timezone 1.0.10 [flutter] - flutter_speed_dial 3.0.5 [flutter] - font_awesome_flutter 9.0.0 [flutter] - google_maps_flutter 2.0.3 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface] - hive 2.0.4 [meta crypto] - hive_flutter 1.0.0 [flutter hive path_provider path] - horizontal_blocked_scroll_physics 3.0.0 [flutter pedantic] - image_cropper 1.4.0 [flutter] - image_picker 0.7.4 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface image_picker_for_web] - in_app_review 2.0.2 [flutter in_app_review_platform_interface] - in_app_update 2.0.0 [flutter] - infinite_scroll_pagination 3.0.1 [flutter sliver_tools] - intl 0.17.0 [clock path] - intl_phone_number_input 0.7.0+2 [flutter meta libphonenumber_plugin equatable collection] - introduction_screen 2.1.0 [flutter dots_indicator] - jiffy 4.1.0 [intl] - json_serializable 4.1.1 [analyzer build build_config collection json_annotation meta path source_gen] - location 4.1.1 [flutter location_platform_interface location_web meta] - logger 1.0.0 - multi_image_picker 4.8.00 [flutter meta] - open_appstore 1.0.2 [flutter] - package_info 2.0.0 [flutter] - path_provider 2.0.1 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - percent_indicator 3.0.1 [flutter] - permission_handler 7.1.0 [flutter meta permission_handler_platform_interface] - photo_gallery 1.0.1 [flutter] - photo_view 0.11.1 [flutter] - provider 5.0.0 [collection flutter nested] - pub_semver 2.0.0 [collection] - pull_to_refresh 1.6.5 [flutter] - pull_to_refresh_notification 2.0.1 [flutter] - quiver 3.0.1 [matcher] - rive 0.7.9 [collection flutter graphs meta] - rxdart 0.26.0 - shake_flutter 14.1.1 [flutter path] - share 2.0.1 [meta mime flutter] - shared_preferences 2.0.5 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows] - slider_button 0.6.0 [vibration flutter] - stream_chat_flutter 2.0.0-nullsafety.3 [flutter stream_chat_flutter_core photo_view rxdart scrollable_positioned_list jiffy flutter_svg flutter_portal cached_network_image shimmer flutter_markdown url_launcher video_player chewie file_picker image_picker flutter_keyboard_visibility video_compress visibility_detector http_parser meta lottie substring_highlight flutter_slidable image_gallery_saver share_plus photo_manager ezanimation synchronized dio characters path_provider video_thumbnail collection] - timeago 3.0.2 - url_launcher 6.0.3 [flutter url_launcher_platform_interface url_launcher_linux url_launcher_macos url_launcher_windows url_launcher_web] - validators 3.0.0 - video_compress 3.0.0 [flutter] - video_player 2.1.1 [meta video_player_platform_interface video_player_web flutter flutter_test] - visibility_detector 0.2.0 [flutter] - wechat_assets_picker 5.5.0 [flutter extended_image photo_manager provider video_player] dev dependencies: - hive_generator 1.1.0 [build source_gen hive analyzer source_helper] dependency overrides: - graphs 1.0.0 transitive dependencies: - _fe_analyzer_shared 21.0.0 [meta] - analyzer 1.5.0 [_fe_analyzer_shared cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml pedantic] - archive 3.1.2 [crypto path] - args 2.1.0 - async 2.5.0 [collection] - boolean_selector 2.1.0 [source_span string_scanner] - build 2.0.1 [analyzer async convert crypto glob logging meta path] - build_config 1.0.0 [checked_yaml json_annotation path pubspec_parse yaml] - characters 1.1.0 - charcode 1.2.0 - checked_yaml 2.0.1 [json_annotation source_span yaml] - cli_util 0.3.0 [meta path] - clock 1.1.0 - convert 3.0.0 [typed_data] - crypto 3.0.1 [collection typed_data] - dart_style 2.0.1 [analyzer args path pub_semver source_span] - device_info_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - dots_indicator 2.0.0 [flutter] - extended_image 4.1.0 [extended_image_library flutter meta] - extended_image_library 3.1.0 [crypto flutter http_client_helper path path_provider] - ezanimation 0.5.0 [flutter] - fake_async 1.2.0 [clock collection] - ffi 1.0.0 - file 6.0.0 [meta path] - file_picker 3.0.1 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface] - firebase 9.0.1 [http http_parser js] - firebase_analytics_platform_interface 2.0.1 [flutter meta] - firebase_analytics_web 0.3.0+1 [firebase firebase_analytics_platform_interface flutter flutter_web_plugins meta] - firebase_auth_platform_interface 4.2.2 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 1.1.2 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.0.3 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.0.3 [collection firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 2.1.4 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 1.0.7 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_remote_config_platform_interface 0.3.0-dev.3 [firebase_core flutter meta plugin_platform_interface] - flutter_blurhash 0.6.0 [flutter meta pedantic] - flutter_cache_manager 3.0.1 [clock collection file flutter http image path path_provider pedantic rxdart sqflite uuid] - flutter_keyboard_visibility 5.0.1 [meta flutter_keyboard_visibility_platform_interface flutter_keyboard_visibility_web flutter] - flutter_keyboard_visibility_platform_interface 2.0.0 [flutter meta plugin_platform_interface] - flutter_keyboard_visibility_web 2.0.0 [flutter_keyboard_visibility_platform_interface flutter_web_plugins flutter] - flutter_plugin_android_lifecycle 2.0.1 [flutter] - flutter_portal 0.4.0 [flutter] - flutter_slidable 0.6.0 [flutter] - flutter_svg 0.22.0 [flutter meta path_drawing vector_math xml] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - freezed_annotation 0.14.1 [collection json_annotation meta] - glob 2.0.1 [async collection file path pedantic string_scanner] - google_maps_flutter_platform_interface 2.0.4 [flutter meta plugin_platform_interface stream_transform collection] - http 0.13.3 [async http_parser meta path pedantic] - http_client_helper 2.0.2 [http] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - image 3.0.2 [archive meta xml] - image_gallery_saver 1.6.9 [flutter] - image_picker_for_web 2.0.0 [image_picker_platform_interface meta flutter flutter_web_plugins] - image_picker_platform_interface 2.1.0 [flutter meta http plugin_platform_interface] - in_app_review_platform_interface 2.0.2 [flutter url_launcher plugin_platform_interface platform] - js 0.6.3 - json_annotation 4.0.1 - libphonenumber 2.0.0 [flutter meta] - libphonenumber_platform_interface 0.3.1 [flutter plugin_platform_interface] - libphonenumber_plugin 0.2.3 [flutter flutter_web_plugins libphonenumber_platform_interface libphonenumber_web libphonenumber] - libphonenumber_web 0.2.0+1 [flutter flutter_web_plugins js libphonenumber_platform_interface] - linkify 4.0.0 - location_platform_interface 2.1.0 [flutter meta plugin_platform_interface] - location_web 3.0.0 [flutter flutter_web_plugins http_parser js location_platform_interface meta] - logging 1.0.1 - lottie 1.0.1 [archive characters charcode collection flutter logging meta path vector_math] - markdown 4.0.0 [args charcode meta] - matcher 0.12.10 [stack_trace] - meta 1.3.0 - mime 1.0.0 - nested 1.0.0 [flutter] - octo_image 1.0.0+1 [flutter flutter_blurhash] - package_config 2.0.0 [path] - path 1.8.0 - path_drawing 0.5.1 [vector_math meta path_parsing flutter] - path_parsing 0.2.1 [vector_math meta] - path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 2.0.0 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.1 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.11.0 - permission_handler_platform_interface 3.3.0 [flutter meta plugin_platform_interface] - petitparser 4.1.0 [meta] - photo_manager 1.1.6 [flutter] - platform 3.0.0 - plugin_platform_interface 2.0.0 [meta] - process 4.0.0 [file path platform] - pubspec_parse 1.0.0 [checked_yaml collection json_annotation pub_semver yaml] - random_color 1.0.6-nullsafety [flutter] - scrollable_positioned_list 0.2.0-nullsafety.0 [flutter collection] - share_plus 2.0.3 [meta mime flutter share_plus_platform_interface share_plus_linux share_plus_macos share_plus_windows share_plus_web] - share_plus_linux 2.0.1 [share_plus_platform_interface file flutter meta url_launcher] - share_plus_macos 2.0.1 [share_plus_platform_interface flutter] - share_plus_platform_interface 2.0.1 [flutter meta mime plugin_platform_interface] - share_plus_web 2.0.1 [share_plus_platform_interface url_launcher flutter flutter_web_plugins meta] - share_plus_windows 2.0.1 [share_plus_platform_interface flutter meta url_launcher] - shared_preferences_linux 2.0.0 [flutter file meta path path_provider_linux shared_preferences_platform_interface] - shared_preferences_macos 2.0.0 [shared_preferences_platform_interface flutter] - shared_preferences_platform_interface 2.0.0 [flutter] - shared_preferences_web 2.0.0 [shared_preferences_platform_interface flutter flutter_web_plugins meta] - shared_preferences_windows 2.0.0 [shared_preferences_platform_interface flutter file meta path path_provider_platform_interface path_provider_windows] - shimmer 2.0.0 [flutter] - sky_engine 0.0.99 - sliver_tools 0.2.2 [flutter] - source_gen 1.0.0 [analyzer async build dart_style glob meta path pedantic source_span] - source_helper 1.1.0 [analyzer collection source_gen] - source_span 1.8.0 [charcode collection path term_glyph] - sqflite 2.0.0+3 [flutter sqflite_common path] - sqflite_common 2.0.0+2 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - stream_chat 2.0.0-nullsafety.1 [async collection dio equatable freezed_annotation http_parser json_annotation logging meta mime rxdart uuid web_socket_channel] - stream_chat_flutter_core 2.0.0-nullsafety.2 [collection flutter meta rxdart stream_chat] - stream_transform 2.0.0 - string_scanner 1.1.0 [charcode source_span] - substring_highlight 1.0.26 [flutter] - synchronized 3.0.0 - term_glyph 1.2.0 - test_api 0.2.19 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher] - typed_data 1.3.0 [collection] - url_launcher_linux 2.0.0 [flutter] - url_launcher_macos 2.0.0 [flutter] - url_launcher_platform_interface 2.0.2 [flutter plugin_platform_interface] - url_launcher_web 2.0.0 [url_launcher_platform_interface meta flutter flutter_web_plugins] - url_launcher_windows 2.0.0 [flutter] - uuid 3.0.4 [crypto] - vector_math 2.1.0 - vibration 1.7.1 [flutter vibration_web] - vibration_web 1.6.2 [flutter flutter_web_plugins] - video_player_platform_interface 4.1.0 [flutter meta flutter_test] - video_player_web 2.0.0 [flutter flutter_web_plugins meta video_player_platform_interface] - video_thumbnail 0.3.3 [flutter] - wakelock 0.4.0 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web] - wakelock_macos 0.1.0 [flutter flutter_web_plugins wakelock_platform_interface] - wakelock_platform_interface 0.2.0 [flutter meta] - wakelock_web 0.2.0 [flutter flutter_web_plugins js wakelock_platform_interface] - watcher 1.0.0 [async path pedantic] - web_socket_channel 2.1.0 [async crypto stream_channel] - win32 2.0.5 [ffi] - xdg_directories 0.2.0 [meta path process] - xml 5.1.0 [collection meta petitparser] - yaml 3.1.0 [collection source_span string_scanner] ```

TheJulianJES commented 3 years ago

This seems to always happen on a Mac for me.

darshankawar commented 3 years ago

@rubenvereecken I tried the official plugin repo on latest stable (2.2.0) and with below dependencies, with which the fetchAndActivate() worked properly:

Screenshot 2021-05-21 at 12 59 20 PM
  firebase_core: ^1.1.0
  firebase_remote_config: ^0.10.0-dev.4
flutter doctor -v ``` [✓] Flutter (Channel stable, 2.2.0, on Mac OS X 10.15.4 19E2269 darwin-x64, locale en-GB) • Flutter version 2.2.0 at /Users/dhs/documents/fluttersdk/flutter • Framework revision b22742018b (5 days ago), 2021-05-14 19:12:57 -0700 • Engine revision a9d88a4d18 • Dart version 2.13.0 [!] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.3, Build version 12C33 ! CocoaPods 1.9.3 out of date (1.10.0 is recommended). CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://flutter.dev/platform-plugins To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions. [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] VS Code (version 1.55.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (3 available) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.212 ! Doctor found issues in 1 category. ```
rubenvereecken commented 3 years ago

Not much I can add to that @darshankawar, like I said, it works 100% of the time on some devices, and breaks 100% of the time on other devices. It might have something to do with iOS persisting more than is good for it despite reinstalls (maybe from an old version of remote_config).

darshankawar commented 3 years ago

This is weird. Maybe somehow the requests are going more than once and previous request is getting cancelled by any chance, but this is just my guess.

Keeping this open for further investigation, as I am unable to replicate it.

salihgueler commented 3 years ago

I was able to reproduce this with.

[✓] Flutter (Channel stable, 2.0.6, on macOS 11.2.3 20D91 darwin-x64, locale en-TR)

and 

firebase_remote_config: ^0.10.0

Here are steps to reproduce:

avi-mastov commented 3 years ago

Happens to me on iOS with

[✓] Flutter (Channel stable, 2.2.3, on macOS 11.1 20C69 darwin-x64, locale en)

and

firebase_remote_config: ^0.10.0+2

If I remove RemoteConfigSettings from the initialization, it works. If I put it back in the code, it throws the exception again. This is the native iOS log:

8.0.0 - [Firebase/RemoteConfig][I-RCN000026] RCN Fetch failure: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://firebaseremoteconfig.googleapis.com/v1/projects/lumen-c6690/namespaces/firebase:fetch?key=AIzaSyCv1tpL0Clk_tLSdmpq9HdVGPOknkRVBZU, NSErrorFailingURLKey=https://firebaseremoteconfig.googleapis.com/v1/projects/lumen-c6690/namespaces/firebase:fetch?key=AIzaSyCv1tpL0Clk_tLSdmpq9HdVGPOknkRVBZU, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <03EE4952-323C-4A08-B376-9091F1DA68E3>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <03EE4952-323C-4A08-B376-9091F1DA68E3>.<1>, NSLocalizedDescription=cancelled}. No cached config result.
8.0.0 - [Firebase/RemoteConfig][I-RCN000026] RCN Fetch failure. Response http error code: 0
vytautas-pranskunas- commented 3 years ago

Failed to submit an app to app store because on iPad it crashes with same error while tested by apple testers. Not crashing on my side. :(

Kal-Elx commented 3 years ago

I had a similar issue which I managed to solve when I was trying to wait for both futures simultaneously.

final List<Future<void>> setupFutures = [
  RemoteConfig.instance.setConfigSettings(
      RemoteConfigSettings(
      fetchTimeout: Duration(seconds: 60),
      minimumFetchInterval: Duration(seconds: 0),
    ),
  );
  RemoteConfig.instance.fetchAndActivate(),
];

await Future.wait(setupFutures);

Awaiting RemoteConfig.instance.setConfigSettings before calling RemoteConfig.instance.fetchAndActivate solved my issue.

@rubenvereecken I see that you are already doing this without succeeding but it might help someone else stumbling upon this issue.

vytautas-pranskunas- commented 3 years ago

I abandoned remote config and added configs to my DB

lesnitsky commented 3 years ago

this just reproduced on CI

rubenvereecken commented 3 years ago

It's honestly pretty wild that this package does this one very simple thing like managing a simple key-value dcument, yet this main use case hasn't been working for multiple months.

ligoriofc commented 3 years ago

I had the same problem, and solved by checking the API KEY at the file GoogleService-info.plist

I restricted the Firebase API to IOS, but the GoogleService-info.plist was with the Android app API KEY.

lesnitsky commented 3 years ago

A concrete cause of the "internal error" in case of CI failures was keychain sharing capability, so make sure to add it with com.firebase group

6748 also propagates an underlying error description up to the dart code, so please, share those in case keychain sharing capability doesn't fix your problem

Kavantix commented 3 years ago

@lesnitsky why should we add our apps to the com.firebase group? That sounds like a security risk.

I managed to work around this error by doing the following:

await RemoteConfig.instance.activate();
// Only fetch after a delay to prevent an internal bug from occurring
// See https://github.com/FirebaseExtended/flutterfire/issues/6196
await Future.delayed(const Duration(seconds: 1));
await RemoteConfig.instance.fetchAndActivate();

Not sure how this would help but somehow adding the delay there fixes the issue

lesnitsky commented 3 years ago

@Kavantix macOS apps prompt for keychain access (firebase SDK reads tokens from keychain). If you're ok with this behavior – no need to add a capability

your workaround doesn't seem to be related to the keychain at all

Also, it's hard to judge what exactly the issue is in each specific case because the error from native wasn't propagating before #6748 was merged.

My comment was related to a CI failure, other cases may have completely different root causes

Kavantix commented 3 years ago

@lesnitsky exactly it is not related to KeyChain, I'm experiencing it on iOS and android (not using macos for this app)

lesnitsky commented 3 years ago

@Kavantix what version are you on?

Kavantix commented 3 years ago

I'm stuck on 0.10.0-dev.3 atm, need to upgrade some things

Kavantix commented 3 years ago

I can see the native error though, probably printed by the iOS sdk:

7.11.0 - [Firebase/RemoteConfig][I-RCN000026] RCN Fetch failure: Error Domain=NSURLErrorDomain Code=-999 "canceled" UserInfo={NSErrorFailingURLStringKey=https://firebaseremoteconfig.googleapis.com/v1/projects/{redacted}/namespaces/firebase:fetch?key={redacted}, NSErrorFailingURLKey=https://firebaseremoteconfig.googleapis.com/v1/projects/{redacted}/namespaces/firebase:fetch?key={redacted}, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <{redacted}>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <{redacted}>.<1>, NSLocalizedDescription=canceled}. No cached config result.
7.11.0 - [Firebase/RemoteConfig][I-RCN000026] RCN Fetch failure. Response http error code: 0

That is also why I tried the delay in the first place, looks like a timing issue to me

coldstar96 commented 2 years ago

I made a mistake and ran fetchAndActivate twice in parallel which caused this issue. Maybe better error message or no-op on second call might help? This might explain why some people resolved this issue by adding a delay.

Repro code:

final config = RemoteConfig.instance;
await Future.wait([
  config.fetchAndActivate(),
  config.fetchAndActivate(),
]);
VagnerWillian commented 2 years ago

I have the same problem. Any solution?

ariefwijaya commented 2 years ago

any updates?

VagnerWillian commented 2 years ago

any updates?

rubenvereecken commented 2 years ago

The (desperate) work-around by @Kavantix seems to point at a potential fix in the package.

@darshankawar @maheshmnj care to take a look?

maheshj01 commented 2 years ago

This issue has passed primary triage and has been labeled for further investigation. Let us wait for the secondary triage's input.

pr-Mais commented 2 years ago

I run into the same issue in one of my apps, the workaround that fixed it was this:

await InternetAddress.lookup('google.com');
await _remoteConfig.fetchAndActivate();

Also, adding a delay as suggested by @Kavantix works, not sure why but this is still reproducible in v2.0.0 only on iOS, works well on Android.

gonft commented 2 years ago

In my case, it was solved by checking the test device network connection.

bhanuka96 commented 2 years ago

I had a similar issue which I managed to solve when I was trying to wait for both futures simultaneously.

final List<Future<void>> setupFutures = [
  RemoteConfig.instance.setConfigSettings(
      RemoteConfigSettings(
      fetchTimeout: Duration(seconds: 60),
      minimumFetchInterval: Duration(seconds: 0),
    ),
  );
  RemoteConfig.instance.fetchAndActivate(),
];

await Future.wait(setupFutures);

Awaiting RemoteConfig.instance.setConfigSettings before calling RemoteConfig.instance.fetchAndActivate solved my issue.

@rubenvereecken I see that you are already doing this without succeeding but it might help someone else stumbling upon this issue.

This is not working on IOS

neiljaywarner commented 2 years ago

@darshankawar is there a solid workaround for this or an ETA for this fix? if it causes ios first install to fail to get remote config values then it would mean firebase remote config won't work for us at all like @lesnitsky but surely there is a reliable fix like @Kavantix etc mentioned. i tried both lookup google.com and ensureinitialized and I'm not having much luck so far.

ciriousjoker commented 2 years ago

I had a similar issue which I managed to solve when I was trying to wait for both futures simultaneously.

final List<Future<void>> setupFutures = [
  RemoteConfig.instance.setConfigSettings(
      RemoteConfigSettings(
      fetchTimeout: Duration(seconds: 60),
      minimumFetchInterval: Duration(seconds: 0),
    ),
  );
  RemoteConfig.instance.fetchAndActivate(),
];

await Future.wait(setupFutures);

Awaiting RemoteConfig.instance.setConfigSettings before calling RemoteConfig.instance.fetchAndActivate solved my issue.

@rubenvereecken I see that you are already doing this without succeeding but it might help someone else stumbling upon this issue.

Thank you so much!

In my case it wasn't as obvious, but the same issue.

I was calling setConfigSettings in the init method of my whole app, while calling fetchAndActivate() in another init method of the first route that's loaded. That would cause the same race condition and this completely unreadable error message.

bhanuka96 commented 2 years ago

I had a similar issue which I managed to solve when I was trying to wait for both futures simultaneously.

final List<Future<void>> setupFutures = [
  RemoteConfig.instance.setConfigSettings(
      RemoteConfigSettings(
      fetchTimeout: Duration(seconds: 60),
      minimumFetchInterval: Duration(seconds: 0),
    ),
  );
  RemoteConfig.instance.fetchAndActivate(),
];

await Future.wait(setupFutures);

Awaiting RemoteConfig.instance.setConfigSettings before calling RemoteConfig.instance.fetchAndActivate solved my issue.

@rubenvereecken I see that you are already doing this without succeeding but it might help someone else stumbling upon this issue.

It's not working for IOS

bhanuka96 commented 2 years ago

My solution for IOS, It's working to me.

      final FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.instance;

      final List<Future<void>> setupFutures = [
        remoteConfig.setConfigSettings(RemoteConfigSettings(minimumFetchInterval: Duration(hours: 1), fetchTimeout: Duration(seconds: 10))),
        Platform.isAndroid ? null : Future.delayed(const Duration(seconds: 1)),
        remoteConfig.fetchAndActivate()
      ];
      await Future.wait(setupFutures);
deepak786 commented 2 years ago

same issue on iOS. None of the above solutions worked for me. any update on this issue?

kjawadDeveloper2 commented 2 years ago

I am facing this issue on android tablet. Any fix.

vukan-markovic commented 2 years ago

I have the same problem on some iOS devices like iPhone 12 and iPhone XR (iOS 15.4.1). Any updates?

maheshj01 commented 2 years ago

Please avoid comments like "same issue", "+1" etc. Comments like these don't provide any additional info But send an unnecessary ping to all the users in this thread. If you are affected by this issue please leave a 👍🏻 on the original post

I have hidden such comments so as to not miss relevant comments in this thread

darshankawar commented 2 years ago

/cc @russellwheatley @Salakar

akmalviya03 commented 2 years ago

I was facing the issue. Our production app also crashed. App crashed the day after google I/0. The app was working fine for the past two weeks. Suddenly it crashed. We thought we had made an error in the new release. After spending a whole week we have tested old builds just to check. And they were also showing the same issue.

D/FRCPlugin(15443): Sending fetchTimeout: 10
W/System  (15443): Ignoring header If-None-Match because its value was null.
D/FRCPlugin(15443): Sending fetchTimeout: 10
E/flutter (15443): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: FormatException: Invalid envelope
E/flutter (15443): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:609:7)
E/flutter (15443): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter (15443): <asynchronous suspension>
E/flutter (15443): #2      MethodChannelFirebaseRemoteConfig.fetchAndActivate (package:firebase_remote_config_platform_interface/src/method_channel/method_channel_firebase_remote_config.dart:146:29)
E/flutter (15443): <asynchronous suspension>
E/flutter (15443): #3      FirebaseRemoteConfig.fetchAndActivate (package:firebase_remote_config/src/firebase_remote_config.dart:87:26)
E/flutter (15443): <asynchronous suspension>
E/flutter (15443): 

To reproduce this issue please use the example

import 'dart:async';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_remote_config/firebase_remote_config.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'firebase_options.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(MaterialApp(
      title: 'Remote Config Example',
      home: FutureBuilder<FirebaseRemoteConfig>(
        future: setupRemoteConfig(),
        builder: (BuildContext context,
            AsyncSnapshot<FirebaseRemoteConfig> snapshot) {
          return snapshot.hasData && snapshot.connectionState == ConnectionState.done
              ? WelcomeWidget(remoteConfig: snapshot.requireData)
              : Container();
        },
      )));
}

class WelcomeWidget extends AnimatedWidget {
  WelcomeWidget({
    required this.remoteConfig,
  }) : super(listenable: remoteConfig);

  final FirebaseRemoteConfig remoteConfig;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Remote Config Example'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('Welcome ${remoteConfig.getString('welcome')}'),
            const SizedBox(
              height: 20,
            ),
            Text('(${remoteConfig.getValue('welcome').source})'),
            Text('(${remoteConfig.lastFetchTime})'),
            Text('(${remoteConfig.lastFetchStatus})'),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () async {
          try {
            // Using zero duration to force fetching from remote server.
            await remoteConfig.setConfigSettings(RemoteConfigSettings(
              fetchTimeout: const Duration(seconds: 10),
              minimumFetchInterval: Duration.zero,
            ));
            await remoteConfig.fetchAndActivate();
          } on PlatformException catch (exception) {
            // Fetch exception.
            print(exception);
          } catch (exception) {
            print(
                'Unable to fetch remote config. Cached or default values will be '
                    'used');
            print(exception);
          }
        },
        child: const Icon(Icons.refresh),
      ),
    );
  }
}

Future<FirebaseRemoteConfig> setupRemoteConfig() async {
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
  final FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.instance;
  remoteConfig.fetchAndActivate();
  await remoteConfig.setDefaults(<String, dynamic>{
    'welcome': 'default welcome',
    'hello': 'default hello',
  });

  return remoteConfig;
}
khalifa007 commented 2 years ago

miserable soulation :

I made new project with latest flutter version 3.0.3 and [firebase_remote_config] 2.0.12 . then move the old project to the new project :) .

Tromp6 commented 2 years ago

For me it was a formatting error inside my local remote config defaults that I setted

knaeckeKami commented 2 years ago

I found this thread because I was just running into issues with Firebase Remote Config on iOS and googled the error message. However, the issue right now is probably a general outage and not a bug in the flutter package. See https://github.com/firebase/firebase-ios-sdk/issues/10017 and https://stackoverflow.com/questions/72995862/receiving-firebaseremoteconfigoperation-config-not-fetched-error-internal-er

russellwheatley commented 2 years ago

@knaeckeKami interesting. That issue has now been fixed on the firebase-ios-sdk, and FlutterFire is using the latest version (9.3.0), can't seem to find the specific fix in the release notes. Is someone able to confirm if this is still a problem?

darshankawar commented 2 years ago

@russellwheatley Same issue was raised yesterday https://github.com/firebase/flutterfire/issues/9227

knaeckeKami commented 2 years ago

@russellwheatley I am not sure if the issue I saw is the same or even related to the bug reported here, but the error message was the same and the circumstances were similar (only happening on iOS, and only on some devices, not on others- probably just due to the 12h minimum fetch time). This is why I choose to comment the issue here.

The issue I was running into was a purely server-side one though. It happened only on iOS and was resolved within a few days without updates to the client sdks. (see https://status.firebase.google.com/incidents/ow6oGue8BtdRaYJZdB9o ).

google-oss-bot commented 2 years ago

Hey @rubenvereecken. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

VagnerWillian commented 2 years ago

So, in the emulator the problem persists, however, in the physical device it works normally.

mockturtl commented 2 years ago

My project uses "staging" and "prod" flavors, with separate Firebase projects. I'm testing in Android, emulator and physical device.

I added Remote Config for staging and prod. It works well on staging.

In the prod build (no code changes), fetchAndActivate() produces

W/System  ( 5364): Ignoring header If-None-Match because its value was null.
D/EGL_emulation( 5364): app_time_stats: avg=49.00ms min=12.23ms max=640.98ms count=21
D/FRCPlugin( 5364): Sending fetchTimeout: 10

I feel like the difference could be in GCP service account permissions, but I don't know what to compare.

pubspec.lock
firebase_core:
    ...
    version: "1.20.0"
firebase_remote_config:
    ...
    version: "2.0.13"
flutter doctor ```sh $ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel beta, 3.3.0-0.2.pre, on LMDE 5 (elsie) 5.18.0-0.bpo.1-amd64, locale en_US.UTF-8) [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0) [✓] Chrome - develop for the web [✗] Linux toolchain - develop for Linux desktop ✗ clang++ is required for Linux development. It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from https://releases.llvm.org/ ✗ CMake is required for Linux development. It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from https://cmake.org/download/ ✗ ninja is required for Linux development. It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from https://github.com/ninja-build/ninja/releases ✗ GTK 3.0 development libraries are required for Linux development. They are likely available from your distribution (e.g.: apt install libgtk-3-dev) [✓] Android Studio (version 2021.2) [✓] IntelliJ IDEA Ultimate Edition (version 2022.2) [✓] Connected device (3 available) [✓] HTTP Host Availability ! Doctor found issues in 1 category. ```
mockturtl commented 2 years ago

SOLVED

re: https://github.com/firebase/flutterfire/issues/6196#issuecomment-1207444803

Cold restart wasn't helping, so I added some logging in FirebaseRemoteConfigPlugin.java.

I suspected a decoding failure based on the first line, but "user not authorized" is helpful.

I/System.out( 6055): OK addOnCompleteListener: {hello={source=default, value=[B@c6d27df}}  
...
I/System.out( 6055): FAIL addOnCompleteListener: com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException: Fetch failed: The user is not authorized to access the project. Please make sure you are using the API key that corresponds to your Firebase project.

Maybe the plugin should add a case for FirebaseRemoteConfigServerException?

russellwheatley commented 2 years ago

Hey @mockturtl, I don't suppose you're able to provide an MCVE so I can reproduce? I'd be happy to resolve this issue once I can reproduce. Thanks!

mockturtl commented 2 years ago

@russellwheatley I'm afraid I can't help with a case to reproduce.

It seems that activating Remote Config in the Firebase dashboard changed my API key, leading to "user not authorized." (The config file was created in 2017, so I guess something needed to migrate.)

I think the plugin should surface the error more clearly:

--- FirebaseRemoteConfigPlugin.java
+++ FirebaseRemoteConfigPlugin.java
@@ -168,6 +168,8 @@
             } else if (exception instanceof FirebaseRemoteConfigClientException) {
               details.put("code", "internal");
               details.put("message", "internal remote config fetch error");
+            } else if (exception instanceof FirebaseRemoteConfigServerException) {
+              // populate details
             } else {
               details.put("code", "unknown");
               details.put("message", "unknown remote config error");