flutterfire
flutterfire copied to clipboard
🐛[firebase_app_check] Unenforced App Check in Flutter Web
Bug report
Describe the bug Sometimes when trying to use appcheck with Unenforced, it gives the following error in both debug and release. Sometimes it works, sometimes it doesn't
Error: [cloud_firestore/unavailable] Failed to get document because the client is offline.
at Object.createErrorWithStack (http://localhost:50806/dart_sdk.js:5419:12)
at Error._throw (http://localhost:50806/dart_sdk.js:21341:18)
at Error.throwWithStackTrace (http://localhost:50806/dart_sdk.js:21335:18)
at async._AsyncCallbackEntry.new.callback (http://localhost:50806/dart_sdk.js:43396:18)
at Object._microtaskLoop (http://localhost:50806/dart_sdk.js:43223:13)
at _startMicrotaskLoop (http://localhost:50806/dart_sdk.js:43229:13)
at http://localhost:50806/dart_sdk.js:38359:9
Steps to reproduce
Using appcheck on the web
Expected behavior
Work even in unforced mode
Sample project
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
(kDebugMode)
? await FirebaseAppCheck.instance.activate(webRecaptchaSiteKey: recaptchaDebugToken)
: await FirebaseAppCheck.instance.activate(
webRecaptchaSiteKey: recaptchaProdToken,
);
Additional context
Unforced mode
In bug mode when taking the token generate and include it in firebase it doesn't work. And use in release mode doesn't work when in unforced mode.
(Keep in mind that this is a problem that sometimes occurs.)
Flutter doctor
Run flutter doctor and paste the output below:
Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.5.1 21G83 darwin-x64, locale pt-BR)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] 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 (2 available)
[✓] HTTP Host Availability
! Doctor found issues in 1 category.
Flutter dependencies
Run flutter pub deps -- --style=compact and paste the output below:
Click To Expand
Dart SDK 2.17.6
Flutter SDK 3.0.5
teste_app 1.0.0
dependencies:
- audioplayers 1.0.1 [audioplayers_android audioplayers_darwin audioplayers_linux audioplayers_platform_interface audioplayers_web audioplayers_windows flutter http path_provider uuid]
- cached_network_image 3.2.1 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web]
- cloud_firestore 3.4.4 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- cupertino_icons 1.0.5
- diacritic 0.1.3
- dropdown_search 5.0.2 [flutter]
- enum_to_string 2.0.1
- firebase_app_check 0.0.7 [firebase_app_check_platform_interface firebase_app_check_web firebase_core firebase_core_platform_interface flutter]
- firebase_auth 3.6.3 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 1.21.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- intl 0.17.0 [clock path]
- multi_select_flutter 4.1.2 [flutter collection]
- package_info_plus 1.4.3+1 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web]
- provider 6.0.3 [collection flutter nested]
- timezone 0.8.0 [path]
- tuple 2.0.0 [quiver]
- url_launcher 6.1.5 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- video_player 2.4.6 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web]
dev dependencies:
- flutter_launcher_icons 0.10.0 [args checked_yaml cli_util image json_annotation path yaml]
- 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]
transitive dependencies:
- archive 3.3.1 [crypto path]
- args 2.3.1
- async 2.8.2 [collection meta]
- audioplayers_android 1.0.1 [audioplayers_platform_interface flutter]
- audioplayers_darwin 1.0.1 [audioplayers_platform_interface flutter]
- audioplayers_linux 1.0.0 [audioplayers_platform_interface flutter]
- audioplayers_platform_interface 1.0.0 [flutter plugin_platform_interface]
- audioplayers_web 1.0.0 [audioplayers_platform_interface flutter flutter_web_plugins]
- audioplayers_windows 1.0.0 [audioplayers_platform_interface flutter]
- 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
- checked_yaml 2.0.1 [json_annotation source_span yaml]
- cli_util 0.3.5 [meta path]
- clock 1.1.0
- cloud_firestore_platform_interface 5.7.1 [collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 2.8.4 [cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js]
- collection 1.16.0
- crypto 3.0.2 [typed_data]
- csslib 0.17.2 [source_span]
- equatable 1.2.6 [collection meta]
- fake_async 1.3.0 [clock collection]
- ffi 2.0.1
- file 6.1.2 [meta path]
- firebase_app_check_platform_interface 0.0.4+15 [firebase_core flutter meta plugin_platform_interface]
- firebase_app_check_web 0.0.6+4 [firebase_app_check_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js]
- firebase_auth_platform_interface 6.5.3 [collection firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 4.2.3 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta]
- firebase_core_platform_interface 4.5.1 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 1.7.2 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_dynamic_links 4.3.5 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface]
- firebase_dynamic_links_platform_interface 0.2.3+10 [firebase_core flutter meta plugin_platform_interface]
- 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_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- html 0.15.0 [csslib source_span]
- http 0.13.5 [async http_parser meta path]
- http_parser 4.0.1 [collection source_span string_scanner typed_data]
- image 3.2.0 [archive meta xml]
- js 0.6.4
- json_annotation 4.6.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_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 2.0.0 [package_info_plus_platform_interface ffi flutter win32]
- path 1.8.1
- 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]
- path_provider_android 2.0.19 [flutter path_provider_platform_interface]
- path_provider_ios 2.0.11 [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.1.2 [ffi flutter path path_provider_platform_interface win32]
- pedantic 1.11.1
- petitparser 5.0.0 [meta]
- platform 3.1.0
- plugin_platform_interface 2.1.2 [meta]
- process 4.2.4 [file path platform]
- quiver 3.1.0 [matcher]
- rxdart 0.27.5
- sky_engine 0.0.99
- source_span 1.8.2 [collection path term_glyph]
- sqflite 2.0.3+1 [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]
- 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]
- typed_data 1.3.1 [collection]
- url_launcher_android 6.0.17 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.0.17 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.0.1 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.0.1 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.1.0 [flutter plugin_platform_interface]
- url_launcher_web 2.0.13 [flutter flutter_web_plugins url_launcher_platform_interface]
- url_launcher_windows 3.0.1 [flutter url_launcher_platform_interface]
- uuid 3.0.6 [crypto]
- vector_math 2.1.2
- video_player_android 2.3.8 [flutter video_player_platform_interface]
- video_player_avfoundation 2.3.5 [flutter video_player_platform_interface]
- video_player_platform_interface 5.1.4 [flutter plugin_platform_interface]
- video_player_web 2.0.12 [flutter flutter_web_plugins video_player_platform_interface]
- week_of_year 2.0.0
- win32 2.7.0 [ffi]
- xdg_directories 0.2.0+1 [meta path process]
- xml 6.1.0 [collection meta petitparser]
- yaml 3.1.1 [collection source_span string_scanner]
Thanks for the report. I tried to replicate this, but I am not getting the error as reported. Maybe I have to try this a bit for longer time to see if I get that error or not.
But considering the fact that you are not seeing this consistently every time, and only sometimes, maybe this could be related to how native sdk behaves in unenforced mode. I am not too sure how should be the behavior in unenforced mode.
Since the error is [cloud_firestore/unavailable] Failed to get document because the client is offline., indicating that server may not be responding properly in unenforced mode.
Keeping this issue open and labeling for further insights on expected behavior or whether this need to be reported in native sdk repo.
That error occurs because you're offline (no internet). Fairly sure it isn't because of app-check. Try removing app-check and see if you still see the same error.
Hey @giovannilima262. 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!
Since there haven't been any recent updates here, I am going to close this issue.
@giovannilima262 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.