Closed cupidchan closed 1 year ago
Here is the video to reproduce the errors: https://user-images.githubusercontent.com/12452100/214127630-b78d52cd-4b71-48c6-ba5a-e964a7d1f881.mov
@darshankawar I saw that you remove the Needs Attention label. Do you have any idea how can I resolve those issues reported above? Thanks!
@darshankawar @lesnitsky I tried to debug this issue further and found an interesting thing: After a user is registered to the local emulator, the Auth instance will be reset and point to the live server. This explains where the 2nd error comes since my live Firebase server does NOT have that newly created user, whom is in the local emulator.
Now, the key question of this issue is: Why FlutterFire reset the useEmulator and connect to the live server after the first attempt? I appreciate if you can share some thoughts as I believe there may be just a simple setting I missed in my code.
@darshankawar @lesnitsky I debug further on this issue over the weekend and found this observation hopefully helpful. But there are still some mysteries I need your help to understand.
http://127.0.0.1:9099/emulator/action?mode=verifyEmail&lang=en&oobCode=ysngrHpCYPTqpFWUhchTR3quF3PTHk7YZmnutS7l9-W8EKaF-4-m9T&apiKey=fake-api-key&continueUrl=http%3A%2F%2Flocalhost%3A62062%2F%23%2Fprofile
main.dart
is called again. This is really unexpected since there is no code change nor Hot Reload. (Question: why the main is called again?)await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
and found that it initiate the Firebase Auth. This is another surprise because FirebaseAuth.instance
is the next line, which should not be started yet.await FirebaseAuth.instance.useAuthEmulator('localhost', 9099);
The big question here is Why the main will be called again?
Your help is greatly apprecaited!
1st error has nothing to do with the firebase_ui β it's a flutter issue.
I was able to reproduce 2nd error only when manually reloading web page β seems to be an issue with the firebase_auth
on web, will follow up with the team.
3rd error β you're trying to open profile page (/#/profile
in url forces the example app to render profile page first). By that time currentUser
is still null
and signInAnonymously
haven't executed yet (could be fixed with await FirebaseAuth.instance.authStateChanges().first
, so you're trying to open the profile page without an authenticated user. Ideally there should be a check in build
method that verifies profile
is never opened without an authenticated user.
By that time
currentUser
is stillnull
this seems to be an issue of the firebase_auth
as well, communicating with the team on that.
Thanks a lot for your reply and assessment @lesnitsky I tried a few more combinations but still not be able to set up the sample code working with Emulator.
signInAnonymously
but i found out that the firebase_ui doesn't work without it. So, I keep this as what the sample app has. I am good without it if there is a way to skip. /#/profile
, how can I set up the universal logic in main so that it can initiate Firebase properly to use the emulator in all routes, such as /#
, /#/profile
, /#/verify-email
... etc. Right now, the sample code works only the very first time when the app starts in `/#' but fails in all other routes as it will point to the live server instead of local emulator. /#/profile
is called, the currentUser
should not be null
but with the email-verified user.Thanks!
This issue is blocked by https://github.com/firebase/flutterfire/issues/10200
Thanks a lot for your reply and assessment @lesnitsky I tried a few more combinations but still not be able to set up the sample code working with Emulator.
- My actual app doesn't need
signInAnonymously
but i found out that the firebase_ui doesn't work without it. So, I keep this as what the sample app has. I am good without it if there is a way to skip.
it does.
- As you can see that the Emulator link redirect a success verification to
/#/profile
, how can I set up the universal logic in main so that it can initiate Firebase properly to use the emulator in all routes, such as/#
,/#/profile
,/#/verify-email
... etc. Right now, the sample code works only the very first time when the app starts in `/#' but fails in all other routes as it will point to the live server instead of local emulator.
This functionality is currently broken and tracked under firebase/flutterfire#10200
- The link provided by the emulator is to verify the user email. And I can confirm that calling that link has successfully verified the email on the Firebase emulator. Therefore, by the time
/#/profile
is called, thecurrentUser
should not benull
but with the email-verified user.
It shouldn't, a workaround would be to wait for FirebaseAuth.instance.authStateChanges().first
, but this would call a real server, not emulator, again firebase/flutterfire#10200
Thanks @lesnitsky! Do you think fixing firebase/flutterfire#10200 will also fix this issue automagically so that the same will work as it should? Or there are still something on the UI side required to do?
just to clarify: do you mean the UI should still work even without signInAnonymously
?
nothing will be required from the UI side
On Mon, Jan 30, 2023, 4:06 PM Cupid Chan @.***> wrote:
Thanks @lesnitsky https://github.com/lesnitsky! Do you think fixing firebase/flutterfire#10200 https://github.com/firebase/flutterfire/issues/10200 will also fix this issue automagically so that the same will work as it should? Or there are still something on the UI side required to do?
β Reply to this email directly, view it on GitHub https://github.com/firebase/FirebaseUI-Flutter/issues/44, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPYUNQN5QIIWY4BLJ5YBTDWU7KIPANCNFSM6AAAAAAUEGD3LY . You are receiving this because you were mentioned.Message ID: @.***>
as of Flutter 3.13.1 β’ channel stable and firebase_ui_auth: 1.7.0 this is no longer reproducible.
Bug report
Describe the bug Exception thrown when trying to register a user
Steps to reproduce
Steps to reproduce the behavior:
1st Error:
2nd Error:
3rd Error:
Expected behavior
No error should be thrown.
Sample project
https://github.com/cupidchan/firebase_ui_auth_issue10279
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
``` PASTE OUTPUT INSIDE HERE ``` Doctor summary (to see all details, run flutter doctor -v): [β] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale en) [β] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [β] Xcode - develop for iOS and macOS (Xcode 14.2) [β] Chrome - develop for the web [β] Android Studio (version 2021.3) [β] VS Code (version 1.74.3) [β] Connected device (2 available) [β] HTTP Host Availability β’ No issues found! --- ### Flutter dependencies Run `flutter pub deps -- --style=compact` and paste the output below:Click To Expand
``` Dart SDK 2.18.6 Flutter SDK 3.3.10 carealth 1.0.0+1 dependencies: - cupertino_icons 1.0.5 - firebase_auth 4.2.4 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.4.1 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_dynamic_links 5.0.11 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_ui_auth 1.1.6 [email_validator firebase_auth firebase_core firebase_dynamic_links firebase_ui_localizations firebase_ui_oauth flutter flutter_localizations flutter_svg] - firebase_ui_localizations 1.0.2 [flutter flutter_localizations intl path] - firebase_ui_oauth_apple 1.0.13 [firebase_auth firebase_ui_oauth flutter] - firebase_ui_oauth_google 1.0.13 [firebase_auth firebase_ui_oauth flutter google_sign_in] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine] - flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math] dev dependencies: - flutter_lints 2.0.1 [lints] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] - test 1.21.4 [analyzer async boolean_selector collection coverage http_multi_server io js node_preamble package_config path pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core] transitive dependencies: - _fe_analyzer_shared 47.0.0 [meta] - _flutterfire_internals 1.0.12 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer 4.7.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - args 2.3.1 - async 2.9.0 [collection meta] - boolean_selector 2.1.0 [source_span string_scanner] - characters 1.2.1 - clock 1.1.1 - collection 1.16.0 - convert 3.1.1 [typed_data] - coverage 1.6.2 [args logging package_config path source_maps stack_trace vm_service] - crypto 3.0.2 [typed_data] - desktop_webview_auth 0.0.11 [crypto flutter http flutter_web_plugins plugin_platform_interface] - email_validator 2.1.17 - fake_async 1.3.1 [clock collection] - file 6.1.4 [meta path] - firebase_auth_platform_interface 6.11.7 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.2.4 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.5.2 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_dynamic_links_platform_interface 0.2.3+26 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_ui_oauth 1.1.6 [desktop_webview_auth firebase_auth firebase_ui_auth flutter_svg flutter] - flutter_svg 1.1.6 [flutter meta path_drawing vector_math xml] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - frontend_server_client 2.1.3 [async path] - glob 2.1.1 [async collection file path string_scanner] - google_sign_in 5.4.2 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web] - google_sign_in_android 6.1.4 [flutter google_sign_in_platform_interface] - google_sign_in_ios 5.5.1 [flutter google_sign_in_platform_interface] - google_sign_in_platform_interface 2.3.0 [flutter plugin_platform_interface quiver] - google_sign_in_web 0.10.2 [flutter flutter_web_plugins google_sign_in_platform_interface js] - http 0.13.5 [async http_parser meta path] - http_multi_server 3.2.1 [async] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - intl 0.17.0 [clock path] - io 1.0.3 [meta path string_scanner] - js 0.6.4 - lints 2.0.1 - logging 1.1.0 - matcher 0.12.12 [stack_trace] - material_color_utilities 0.1.5 - meta 1.8.0 - mime 1.0.4 - node_preamble 2.0.1 - package_config 2.1.0 [path] - path 1.8.2 - path_drawing 1.0.1 [vector_math meta path_parsing flutter] - path_parsing 1.0.1 [vector_math meta] - petitparser 5.1.0 [meta] - plugin_platform_interface 2.1.3 [meta] - pool 1.5.1 [async stack_trace] - pub_semver 2.1.3 [collection meta] - quiver 3.2.1 [matcher] - shelf 1.4.0 [async collection http_parser path stack_trace stream_channel] - shelf_packages_handler 3.0.1 [path shelf shelf_static] - shelf_static 1.1.1 [convert http_parser mime path shelf] - shelf_web_socket 1.0.3 [shelf stream_channel web_socket_channel] - sky_engine 0.0.99 - source_map_stack_trace 2.1.1 [path source_maps stack_trace] - source_maps 0.10.11 [source_span] - source_span 1.9.0 [collection path term_glyph] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - string_scanner 1.1.1 [source_span] - term_glyph 1.2.1 - test_api 0.4.12 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - test_core 0.4.16 [analyzer async args boolean_selector collection coverage frontend_server_client glob io meta package_config path pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher test_api] - typed_data 1.3.1 [collection] - vector_math 2.1.2 - vm_service 9.4.0 - watcher 1.0.2 [async path] - web_socket_channel 2.3.0 [async crypto stream_channel] - webkit_inspection_protocol 1.2.0 [logging] - xml 6.1.0 [collection meta petitparser] - yaml 3.1.1 [collection source_span string_scanner] ```