flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [firebase_auth_web] Cannot read properties of undefined (reading 'auth')

Open rutaba1 opened this issue 3 years ago • 4 comments

Bug report

Describe the bug I am using flutter fire on my flutter web app and flutterfire_ui plugin for auth. I'm initialising the firebase dependencies in index.html file like this:

But as soon as I hit sign in button I get an exception. Btw I'm using signInWithEmail with flutterfire_ui.

TypeError: Cannot read properties of undefined (reading 'auth') at Object.getAuthInstance (http://localhost:57052/packages/firebase_auth_web/src/interop/auth.dart.lib.js:1037:70) at get [_delegate] (http://localhost:57052/packages/firebase_auth_web/firebase_auth_web.dart.lib.js:81:49) at new firebase_auth_web.FirebaseAuthWeb.new (http://localhost:57052/packages/firebase_auth_web/firebase_auth_web.dart.lib.js:476:9) at firebase_auth_web.FirebaseAuthWeb..delegateFor (http://localhost:57052/packages/firebase_auth_web/firebase_auth_web.dart.lib.js:86:14) at FirebaseAuthPlatform.instanceFor (http://localhost:57052/packages/firebase_auth_platform_interface/src/types.dart.lib.js:1665:77) at get [_delegate] (http://localhost:57052/packages/firebase_auth/firebase_auth.dart.lib.js:91:135) at firebase_auth.FirebaseAuth..signInWithCredential (http://localhost:57052/packages/firebase_auth/firebase_auth.dart.lib.js:272:68) at signInWithCredential.next () at runBody (http://localhost:57052/dart_sdk.js:43013:34) at Object._async [as async] (http://localhost:57052/dart_sdk.js:43044:7) at firebase_auth.FirebaseAuth..signInWithCredential (http://localhost:57052/packages/firebase_auth/firebase_auth.dart.lib.js:271:20) at email_flow.EmailFlow.new.signIn (http://localhost:57052/packages/flutterfire_ui/src/auth/configs/email_link_provider_configuration.dart.lib.js:13647:47) at signIn.next () at runBody (http://localhost:57052/dart_sdk.js:43013:34) at Object._async [as async] (http://localhost:57052/dart_sdk.js:43044:7) at email_flow.EmailFlow.new.signIn (http://localhost:57052/packages/flutterfire_ui/src/auth/configs/email_link_provider_configuration.dart.lib.js:13646:20) at email_flow.EmailFlow.new.onCredentialReceived (http://localhost:57052/packages/flutterfire_ui/src/auth/configs/email_link_provider_configuration.dart.lib.js:13710:40) at onCredentialReceived.next () at runBody (http://localhost:57052/dart_sdk.js:43013:34) at Object._async [as async] (http://localhost:57052/dart_sdk.js:43044:7) at email_flow.EmailFlow.new.onCredentialReceived (http://localhost:57052/packages/flutterfire_ui/src/auth/configs/email_link_provider_configuration.dart.lib.js:13691:20) at [onCredentialReceived] (http://localhost:57052/packages/flutterfire_ui/src/auth/configs/email_link_provider_configuration.dart.lib.js:14050:20) at email_flow.EmailFlow.new.onCredentialReceived$ (http://localhost:57052/packages/flutterfire_ui/src/auth/configs/email_link_provider_configuration.dart.lib.js:14038:45) at onCredentialReceived$.next () at runBody (http://localhost:57052/dart_sdk.js:43013:34) at Object._async [as async] (http://localhost:57052/dart_sdk.js:43044:7) at email_flow.EmailFlow.new.onCredentialReceived (http://localhost:57052/packages/flutterfire_ui/src/auth/configs/email_link_provider_configuration.dart.lib.js:14029:20) at email_flow.EmailFlow.new.setCredential (http://localhost:57052/packages/flutterfire_ui/src/auth/configs/email_link_provider_configuration.dart.lib.js:13642:12) at email_flow.EmailFlow.new.setEmailAndPassword (http://localhost:57052/packages/flutterfire_ui/src/auth/configs/email_link_provider_configuration.dart.lib.js:14025:12) at [_submit] (http://localhost:57052/packages/flutterfire_ui/src/auth/configs/email_link_provider_configuration.dart.lib.js:11983:16) at http://localhost:57052/packages/flutterfire_ui/src/auth/widgets/password_input.dart.lib.js:120:23 at [_finalizeEditing] (http://localhost:57052/packages/flutter/src/widgets/widget_inspector.dart.lib.js:37361:9) at editable_text.EditableTextState.new.performAction (http://localhost:57052/packages/flutter/src/widgets/widget_inspector.dart.lib.js:37217:37) at text_input.TextInput.._handleTextInputInvocation (http://localhost:57052/packages/flutter/src/services/text_formatter.dart.lib.js:2300:64) at _handleTextInputInvocation.next () at runBody (http://localhost:57052/dart_sdk.js:43013:34) at Object._async [as async] (http://localhost:57052/dart_sdk.js:43044:7) at [_handleTextInputInvocation] (http://localhost:57052/packages/flutter/src/services/text_formatter.dart.lib.js:2243:20) at OptionalMethodChannel._handleAsMethodCall (http://localhost:57052/packages/flutter/src/services/restoration.dart.lib.js:1647:57) at _handleAsMethodCall.next () at runBody (http://localhost:57052/dart_sdk.js:43013:34) at Object._async [as async] (http://localhost:57052/dart_sdk.js:43044:7) at [_handleAsMethodCall] (http://localhost:57052/packages/flutter/src/services/restoration.dart.lib.js:1644:20) at http://localhost:57052/packages/flutter/src/services/restoration.dart.lib.js:1640:126 at http://localhost:57052/packages/flutter/src/services/restoration.dart.lib.js:6504:33 at Generator.next () at runBody (http://localhost:57052/dart_sdk.js:43013:34) at Object._async [as async] (http://localhost:57052/dart_sdk.js:43044:7) at http://localhost:57052/packages/flutter/src/services/restoration.dart.lib.js:6501:24 at Object.invoke2 (http://localhost:57052/dart_sdk.js:203786:7) at ui._ChannelCallbackRecord.new.invoke (http://localhost:57052/dart_sdk.js:140854:15) at ui._Channel.new.push (http://localhost:57052/dart_sdk.js:140931:54) at ui.ChannelBuffers.new.push (http://localhost:57052/dart_sdk.js:141027:29) at _engine.EnginePlatformDispatcher.__.invokeOnPlatformMessage (http://localhost:57052/dart_sdk.js:182711:27) at _engine.TextEditingChannel.new.performAction (http://localhost:57052/dart_sdk.js:197986:49) at http://localhost:57052/dart_sdk.js:198077:24 at _engine.GloballyPositionedTextEditingStrategy.new.maybeSendAction (http://localhost:57052/dart_sdk.js:189211:40) at Object._checkAndCall (http://localhost:57052/dart_sdk.js:5603:16) at Object.dcall (http://localhost:57052/dart_sdk.js:5608:17) at HTMLInputElement. (http://localhost:57052/dart_sdk.js:115918:21)

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
[✓] Flutter (Channel stable, 2.10.0, on macOS 11.6 20G165 darwin-x64, locale en-GB)
    • Flutter version 2.10.0 at /Users/hinnarutaba/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5f105a6ca7 (6 months ago), 2022-02-01 14:15:42 -0800
    • Engine revision 776efd2034
    • Dart version 2.16.0
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/hinnarutaba/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)

[✓] VS Code (version 1.67.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.40.0

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.134

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!


Flutter dependencies

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

Click To Expand
  firebase_auth: 3.4.1
  firebase_auth_web: 3.3.19
  firebase_core: 1.13.1
  flutterfire_ui: 0.4.2+2

rutaba1 avatar Jul 26 '22 08:07 rutaba1

@rutaba1 Please upgrade your stable version to latest (3.0.5) and below plugins to their latest versions and try again:

https://pub.dev/packages/flutterfire_ui/changelog#0431 https://pub.dev/packages/firebase_auth/changelog#351 https://pub.dev/packages/firebase_auth_web/changelog#411

darshankawar avatar Jul 26 '22 10:07 darshankawar

@darshankawar Updating to latest dependencies is causing persistence issue that's why I'm trying to stick to the old versions

rutaba1 avatar Jul 26 '22 11:07 rutaba1

There's an active PR to fix persistence issue that you subscribe to for further updates.

darshankawar avatar Jul 26 '22 13:07 darshankawar

Hey @rutaba1. 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!

google-oss-bot avatar Aug 04 '22 01:08 google-oss-bot

Since there haven't been any recent updates here, I am going to close this issue.

@rutaba1 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.

google-oss-bot avatar Aug 15 '22 01:08 google-oss-bot