Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [firebase auth ui] Error reported in console when verifying email address using web app #20

Open
graemep-nz opened this issue May 5, 2023 · 6 comments
Assignees
Labels

Comments

@graemep-nz
Copy link

Bug report

Using google chrome and a web app, register a new email address and wait for the verify email to be sent. Without clicking on the link in the verify email, click "continue" or "go back" on the verify email screen. An error is reported in the android studio console
Error: Looking up a deactivated widget's ancestor is unsafe.

Click To Expand
Error: Looking up a deactivated widget's ancestor is unsafe.
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49  throw_
packages/flutter/src/widgets/framework.dart 4334:9                                                                         <fn>
packages/flutter/src/widgets/framework.dart 4347:14                                                                        [_debugCheckStateIsActiveForAncestorLookup]
packages/flutter/src/widgets/framework.dart 4368:12                                                                        dependOnInheritedWidgetOfExactType
packages/firebase_ui_auth/src/actions.dart 97:19                                                                           maybeOf
packages/firebase_ui_auth/src/actions.dart 22:33                                                                           ofType
packages/firebase_ui_auth/firebase_ui_auth.dart 147:39                                                                     signOut
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50            <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1660:54                                          runUnary
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 147:18                                    handleValue
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 767:44                                    handleValueCallback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 796:13                                    _propagateToListeners
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 567:5                                     [_completeWithValue]
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 640:7                                     callback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 40:11                              _microtaskLoop
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 49:5                               _startMicrotaskLoop
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15           <fn>

After the above error, if you then attempt to sign in, it accepts the sign in but goes to the verify email screen (as it should) and it shows the large spinning circle indefinitely but fails to send a new verify email so it is now not possible to verify the email address, nor is it possible to delete the new account. If you click "forgot password" you can reset the password and verify the email address at the same time - however when I clicked "continue" the app died completely with no error message in the console and a blank browser window.

After restarting the app, now try to sign in with a second email address that is previously registered and the screen shows a red error message
"An internal auth error has occurred"

Steps to reproduce

As above.

Expected behavior

The console should not report an error and the system should not prevent someone from repeating the verify operation.

Also, when the continue button is clicked, if the email address has not been verified it should say that verification has not been done and stay on the same screen. The go back button can be used to go back to the sign in screen.

Eventually the system got into a state where it was not possible to register a new email address, the "forgot password" mechanism stopped working and registering a new email address gets an error on the screen in red "Please verify the new email before changing email". i.e. the system is completely useless - I can't sign in nor can I register a new email address.

Sample project

Use the example app in the git repo of firebase auth UI which uses the "flutterfire-e2e-tests" project on firebase


Additional context

Add any other context about the problem here.


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.7.12, on Microsoft Windows [Version 10.0.22621.1635], locale en-NZ)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.1)
[√] Android Studio (version 2022.2)
[√] VS Code (version 1.70.2)
[√] VS Code, 64-bit edition (version 1.77.3)
[√] Connected device (3 available)
[√] HTTP Host Availability

• No issues found!

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
flutter pub deps -- --style=compact
Dart SDK 2.19.6
Flutter SDK 3.7.12
firebase_with_flutter 1.0.0+1

dependencies:
- cloud_firestore 4.5.3 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- cupertino_icons 1.0.5
- email_validator 2.1.17
- firebase_auth 4.4.2 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_auth_platform_interface 6.13.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_core 2.10.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_core_platform_interface 4.6.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_dynamic_links 5.1.1 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface]
- firebase_ui_auth 1.2.4 [email_validator firebase_auth firebase_core firebase_dynamic_links firebase_ui_localizations firebase_ui_oauth firebase_ui_shared flutter flutter_localizations flutter_svg]
- firebase_ui_localizations 1.3.1 [flutter flutter_localizations path]
- firebase_ui_oauth 1.2.4 [desktop_webview_auth firebase_auth firebase_ui_auth firebase_ui_shared flutter_svg flutter]
- firebase_ui_oauth_apple 1.1.4 [firebase_auth firebase_ui_oauth flutter]
- firebase_ui_oauth_facebook 1.1.4 [firebase_auth firebase_ui_oauth flutter flutter_facebook_auth]
- firebase_ui_oauth_google 1.0.21 [firebase_auth firebase_ui_oauth flutter google_sign_in]
- firebase_ui_oauth_twitter 1.1.4 [flutter firebase_auth firebase_ui_oauth twitter_login]
- flutter 0.0.0 [characters collection js material_color_utilities meta vector_math sky_engine]
- flutter_localizations 0.0.0 [flutter intl characters clock collection js material_color_utilities meta path vector_math]
- flutter_svg 1.1.6 [flutter meta path_drawing vector_math xml]
- google_fonts 4.0.4 [flutter http path_provider crypto]

dev dependencies:
- drive 1.0.0-1.0.nullsafety.5 [test_api flutter_test flutter_driver stack_trace flutter]
- flutter_driver 0.0.0 [file flutter flutter_test fuchsia_remote_debug_protocol path meta vm_service webdriver archive async boolean_selector characters clock collection crypto js matcher material_color_utilities platform process source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math]
- flutter_facebook_auth 4.4.1+1 [flutter flutter_facebook_auth_platform_interface flutter_facebook_auth_web]
- 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 js matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph]
- google_sign_in 5.4.4 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web]
- http 0.13.6 [async http_parser meta]
- integration_test 0.0.0 [flutter flutter_driver flutter_test path vm_service archive async boolean_selector characters clock collection crypto fake_async file js matcher material_color_utilities meta source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math webdriver]
- mockito 5.4.0 [analyzer build code_builder collection dart_style matcher meta path source_gen test_api]
- test 1.22.0 [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]
- twitter_login 4.3.2 [crypto flutter http]

transitive dependencies:
- _fe_analyzer_shared 59.0.0 [meta]
- _flutterfire_internals 1.1.1 [collection firebase_core firebase_core_platform_interface flutter meta]
- analyzer 5.11.1 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml]
- archive 3.3.2 [crypto path]
- args 2.4.0
- async 2.10.0 [collection meta]
- boolean_selector 2.1.1 [source_span string_scanner]
- build 2.3.1 [analyzer async convert crypto glob logging meta path]
- built_collection 5.1.1
- built_value 8.4.4 [built_collection collection fixnum meta]
- characters 1.2.1
- clock 1.1.1
- cloud_firestore_platform_interface 5.12.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 3.4.2 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js]
- code_builder 4.4.0 [built_collection built_value collection matcher meta]
- collection 1.17.0
- convert 3.1.1 [typed_data]
- coverage 1.6.3 [args logging package_config path source_maps stack_trace vm_service]
- crypto 3.0.2 [typed_data]
- dart_style 2.3.0 [analyzer args path pub_semver source_span]
- desktop_webview_auth 0.0.11 [crypto flutter http flutter_web_plugins plugin_platform_interface]
- fake_async 1.3.1 [clock collection]
- ffi 2.0.1
- file 6.1.4 [meta path]
- firebase_auth_web 5.3.2 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta]
- firebase_core_web 2.3.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_dynamic_links_platform_interface 0.2.4+1 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_ui_shared 1.2.0 [flutter]
- fixnum 1.1.0
- flutter_facebook_auth_platform_interface 3.2.0 [flutter plugin_platform_interface]
- flutter_facebook_auth_web 3.2.0 [flutter flutter_web_plugins js flutter_facebook_auth_platform_interface]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- frontend_server_client 3.2.0 [async path]
- fuchsia_remote_debug_protocol 0.0.0 [process vm_service file meta path platform]
- glob 2.1.1 [async collection file path string_scanner]
- google_sign_in_android 6.1.14 [flutter google_sign_in_platform_interface]
- google_sign_in_ios 5.6.2 [flutter google_sign_in_platform_interface]
- google_sign_in_platform_interface 2.4.0 [flutter plugin_platform_interface quiver]
- google_sign_in_web 0.10.2+1 [flutter flutter_web_plugins google_sign_in_platform_interface js]
- 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.4 [meta path string_scanner]
- js 0.6.5 [meta]
- lints 2.0.1
- logging 1.1.1
- matcher 0.12.13 [meta stack_trace]
- material_color_utilities 0.2.0
- meta 1.8.0
- mime 1.0.4
- node_preamble 2.0.2
- 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]
- path_provider 2.0.14 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows]
- path_provider_android 2.0.27 [flutter path_provider_platform_interface]
- path_provider_foundation 2.2.2 [flutter path_provider_platform_interface]
- path_provider_linux 2.1.10 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.0.6 [flutter platform plugin_platform_interface]
- path_provider_windows 2.1.6 [ffi flutter path path_provider_platform_interface win32]
- petitparser 5.1.0 [meta]
- platform 3.1.0
- plugin_platform_interface 2.1.4 [meta]
- pool 1.5.1 [async stack_trace]
- process 4.2.4 [file path platform]
- 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_gen 1.2.7 [analyzer async build dart_style glob path source_span yaml]
- source_map_stack_trace 2.1.1 [path source_maps stack_trace]
- source_maps 0.10.12 [source_span]
- source_span 1.9.1 [collection path term_glyph]
- stack_trace 1.11.0 [path]
- stream_channel 2.1.1 [async]
- string_scanner 1.2.0 [source_span]
- sync_http 0.3.1
- term_glyph 1.2.1
- test_api 0.4.16 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher]
- test_core 0.4.20 [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.4
- vm_service 9.4.0
- watcher 1.0.2 [async path]
- web_socket_channel 2.4.0 [async crypto stream_channel]
- webdriver 3.0.1 [archive matcher path stack_trace sync_http]
- webkit_inspection_protocol 1.2.0 [logging]
- win32 4.1.3 [ffi]
- xdg_directories 1.0.0 [meta path process]
- xml 6.2.2 [collection meta petitparser]
- yaml 3.1.1 [collection source_span string_scanner]

@danagbemava-nc
Copy link
Contributor

Hi @graemep-nz, I followed the steps you outlined above but I did not get any errors in my console (either chrome or IDE) when I hit go back after the sign up.

I also attempted to login with the credentials and in my initial tests, I did not encounter the infinite loading you mentioned. In subsequent tests, firebase blocks the messages because I've been sending too many requests.

Is there any additional information you can provide? It seems all is working just fine on my end.

The recording below is for the first error that you reported (looking up a deactivated widget).

recording
Screen.Recording.2023-05-08.at.10.17.46.mov

@graemep-nz
Copy link
Author

graemep-nz commented May 8, 2023

I'll see if I can recover my ability to login to firebase by deleting a local cache or something, if I can't I'll try on a different machine. In the meantime, do you have any idea what causes this error message
"Please verify the new email before changing email".
What conditions result in this error message being produced?

Also, what do you mean firebase blocks because you sent too many requests - what kind of requests were you sending and how many does it take for firebase to block?

@danagbemava-nc
Copy link
Contributor

In the meantime, do you have any idea what causes this error message
"Please verify the new email before changing email".
What conditions result in this error message being produced?

Unfortunately, I don't know what condition trigger this. How often do you see this?

Also, what do you mean firebase blocks because you sent too many requests - what kind of requests were you sending and how many does it take for firebase to block?

It was the email invites. I might have tested with a few too many accounts & sent a few too many emails

@graemep-nz
Copy link
Author

graemep-nz commented May 9, 2023

It might have been that firebase was blocking me like you said it was doing to you because tonight the app is usable again and I can log in and log out etc. I suspect the error message "Please verify the new email before changing email" comes from the remote firebase server as the error text does not appear in any of the local "localization" source files nor in any of the local firebase_auth source files.

Did you notice I was using an outdated version of firebase_ui_auth. I've changed to this but the problem is still there

  firebase_ui_auth: ^1.3.0
  firebase_ui_localizations: ^1.4.0

I can consistently reproduce the error
Error: Looking up a deactivated widget's ancestor is unsafe.
which comes from sign out here
packages/firebase_ui_auth/firebase_ui_auth.dart 147:39

Just in case you didn't could you please try it like this

  1. register a new email address
  2. wait for the verify email to arrive but don't click on it
  3. click "continue" in the app. It should say "we couldn't verify your email address"
  4. click "go back"

now you should get the error message "unsafe...".
I don't get the error every single time but most of the time. If you don't get the error, try just doing "go back" instead of continue, or try with a different email address.

I also got a new error tonight as below. I am testing with three different gmail email addresses. The system lets me register them all from the same PC/ app so I have been trying things like signing up then deleting the account and trying to sign in etc.

Error: setState() or markNeedsBuild() called when widget tree was locked.
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49      throw_
packages/flutter/src/widgets/framework.dart 4636:9                                                                             <fn>
packages/flutter/src/widgets/framework.dart 4645:14                                                                            markNeedsBuild
packages/flutter/src/widgets/framework.dart 1153:5                                                                             setState
packages/firebase_ui_auth/src/widgets/editable_user_display_name.dart 61:7                                                     _finishEditing

This is the function that is giving the "ancestor ... unsafe" error message. The error is with the "ofType" function call which occurs after the await has completed. The caller isn't doing an await - it can't - it's in a build method. Why is the signOut function doing a callback when the goBack button has already done a callback.

A delayed callback using build context seems wrong.
Sorry about the formatting below - the "insert code" thing is not working

static Future<void> signOut({
    BuildContext? context,
    FirebaseAuth? auth,
  }) async {
    final resolvedAuth = auth ?? FirebaseAuth.instance;
    await OAuthProviders.signOut(resolvedAuth);
    await resolvedAuth.signOut();

    if (context != null) {
      final action = FirebaseUIAction.ofType<SignedOutAction>(context);
      action?.callback(context);
    }
  }

The caller isn't doing an await

 '/verify-email': (context) {
          return EmailVerificationScreen(
            headerBuilder: headerIcon(Icons.verified),
            sideBuilder: sideIcon(Icons.verified),
            actionCodeSettings: actionCodeSettings,
            actions: [
              EmailVerifiedAction(() {
                Navigator.pushReplacementNamed(context, '/profile');
              }),
              AuthCancelledAction((context) {
                FirebaseUIAuth.signOut(context: context);
                Navigator.pushReplacementNamed(context, '/');
              }),
            ],
          );
        },
UniversalButton(
          variant: ButtonVariant.text,
          text: l.goBackButtonLabel,
          onPressed: () {
            FirebaseUIAction.ofType<AuthCancelledAction>(context)
                ?.callback(context);
          },
        )

@danagbemava-nc
Copy link
Contributor

I still cannot seem to reproduce the issue and I keep running to firebase blocking the email so the buttons are never shown.
See the recording below.

I'll be labeling this for further insight & investigation from the team

recording
Screen.Recording.2023-05-11.at.10.14.29.mov

@graemep-nz
Copy link
Author

Just tell Andreii Lesnitsky that the callback in the signOut function causes a problem for the example app
@lesnitsky
image
The example app could pass null to the signOut function to stop the callback occurring. There's no error message that comes back from the signOut function if the signout fails so what is the point of notifying the user that the signout has completed. Is the GUI supposed to block until the signout completes - the example app doesn't wait for the callback, nor does it set up any actions for it.

@lesnitsky lesnitsky self-assigned this May 11, 2023
@lesnitsky lesnitsky transferred this issue from firebase/flutterfire Aug 18, 2023
@lesnitsky lesnitsky added the auth label Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants