Skip to content

🐛 [flutterfire] Firebase initialization exception: "Error: Expected a value of type 'Object', but got one of type 'Null' #11689

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

Closed
Codseus opened this issue Oct 11, 2023 · 7 comments
Labels
platform: web Issues / PRs which are specifically for web. plugin: core resolution: duplicate This issue or pull request already exists type: bug Something isn't working

Comments

@Codseus
Copy link

Codseus commented Oct 11, 2023

Bug report

Describe the bug
Runs fine if "flutter run" is used, but throws exception with debug mode (F5).

full error code:

Exception has occurred.
"Error: Expected a value of type 'Object', but got one of type 'Null'
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 294:49      throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 127:3       castError
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 742:12  cast
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 78:24                 as
packages/firebase_core_web/src/firebase_core_web.dart 87:20                       get [_ignoredServiceScripts]
packages/firebase_core_web/src/firebase_core_web.dart 163:28                      _initializeCore
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54                runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5                _async
packages/firebase_core_web/src/firebase_core_web.dart 155:31                      [_initializeCore]
packages/firebase_core_web/src/firebase_core_web.dart 197:11                      initializeApp
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54                runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5                _async
packages/firebase_core_web/src/firebase_core_web.dart 193:44                      initializeApp
packages/firebase_core/src/firebase.dart 43:47                                    initializeApp
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54                runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5                _async
packages/firebase_core/src/firebase.dart 39:43                                    initializeApp
packages/project123/main.dart 6:18                                               main
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54                runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5                _async
packages/project123/main.dart 5:10                                               main$
web_entrypoint.dart 24:31                                                         <fn>
lib/ui_web/ui_web/initialization.dart 41:15                                       <fn>
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50                <fn>
dart-sdk/lib/async/zone.dart 1661:54                                              runUnary
dart-sdk/lib/async/future_impl.dart 156:18                                        handleValue
dart-sdk/lib/async/future_impl.dart 840:44                                        handleValueCallback
dart-sdk/lib/async/future_impl.dart 869:13                                        _propagateToListeners
dart-sdk/lib/async/future_impl.dart 641:5                                         [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 715:7                                         callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                                  _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                                   _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:15               <fn>
"

Steps to reproduce

Steps to reproduce the behavior:

  1. Install latest flutter version (3.13.6)
  2. Create a firebase project
  3. add firebase core and auth dependencies
  4. configure with flutterfire configure
  5. add initalizeApp to main function.
  6. run with debug mode All exceptions and Uncaught Exceptions enabled.

Expected behavior

Has to work fine.

Sample project

Just use flutter create, don't add anything but this to main.dart:

void main() async {
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
  runApp(const MyApp());
}

Additional context

Debug mode suddenly started throwing this exception, probably after I upgraded flutter version.
I was using windows but, just to make sure I didn't mess anything on my end, I installed fedora on my other drive.
Still same issue happens.


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.13.6, on Fedora Linux 38 (KDE Plasma) 6.2.9-300.fc38.x86_64, locale
    en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.83.0)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!


Flutter dependencies

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

Click To Expand
Dart SDK 3.1.3
Flutter SDK 3.13.6
restauranco 1.0.0+1

dependencies:
- cupertino_icons 1.0.6
- firebase_auth 4.10.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 2.17.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math web sky_engine]

dev dependencies:
- flutter_lints 2.0.3 [lints]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math async boolean_selector characters collection material_color_utilities meta source_span stream_channel string_scanner term_glyph web]

transitive dependencies:
- _flutterfire_internals 1.3.7 [collection firebase_core firebase_core_platform_interface flutter meta]
- async 2.11.0 [collection meta]
- boolean_selector 2.1.1 [source_span string_scanner]
- characters 1.3.0
- clock 1.1.1
- collection 1.17.2
- fake_async 1.3.1 [clock collection]
- firebase_auth_platform_interface 6.19.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 5.8.2 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser js meta]
- firebase_core_platform_interface 4.8.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.8.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math web]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- js 0.6.7 [meta]
- lints 2.1.1
- matcher 0.12.16 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.5.0 [collection]
- meta 1.9.1
- path 1.8.3
- plugin_platform_interface 2.1.6 [meta]
- sky_engine 0.0.99
- source_span 1.10.0 [collection path term_glyph]
- stack_trace 1.11.0 [path]
- stream_channel 2.1.1 [async]
- string_scanner 1.2.0 [source_span]
- term_glyph 1.2.1
- test_api 0.6.0 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- typed_data 1.3.2 [collection]
- vector_math 2.1.4
- web 0.1.4-beta

@Codseus Codseus added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Oct 11, 2023
@Codseus Codseus changed the title 🐛 [flutterfire] Your issue title here 🐛 [flutterfire] Firebase initialization exception: "Error: Expected a value of type 'Object', but got one of type 'Null' Oct 11, 2023
@Codseus
Copy link
Author

Codseus commented Oct 11, 2023

Actually, even if I use flutter run, I don't get the exception error but, when user tries to log in with firebase auth it freezes the app, most likely because Firebase didn't initialize.
For 2 days I couldn't develop my app, I don't know if this is a problem with latest flutter version, but please let me know which version to downgrade, so I can move on with development.

@darshankawar darshankawar added the triage Issue is currently being triaged. label Oct 12, 2023
@darshankawar
Copy link

Thanks for the report @Codseus

6. run with debug mode All exceptions and Uncaught Exceptions enabled.

I am wondering if this is related to dart specifically and it's effect rippled to flutterfire plugins. See dart-lang/sdk#53334 and check if it helps further or not.

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Oct 12, 2023
@Codseus
Copy link
Author

Codseus commented Oct 12, 2023

Nothing is working, I read through every issue here but none has a solution, I downgraded to flutter 3.10.0 and downgraded firebase core and firebase auth dependencies too, but still the same problem.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Oct 12, 2023
@darshankawar
Copy link

I am unable to replicate the error after following all the steps you mentioned. Can you reconfigure your firebase integration by first updating the cli tool and then reselecting the firebase project ?

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Oct 13, 2023
@Codseus
Copy link
Author

Codseus commented Oct 13, 2023

My flutterfire cli is already up to date, but I reactivated again to make sure. I did flutterfire configure again. Still getting the same exception.

I added this line on my main.dart to check if firebase initializes late,

Firebase.apps.isEmpty
      ? print('Firebase not initialized')
      : print('Firebase initialized');

I am not getting any print on debug mode since the exception stops the app but when running with flutter run, I am always getting 'firebase initialized', I am never getting the not initialized printed. Maybe this is a flutter problem rather than flutterfire problem, or a firebase_core problem.

Note:
Even though Firebase initializes fine on flutter run, If I try to listen authStateChanges when no user is logged, my app freezes so I cannot do redirects on my login page. I guess I have to work with that for now until this problem is fixed.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Oct 13, 2023
@darshankawar
Copy link

I am unable to replicate the error as verified earlier, but based on the report, labeling it for team's attention.

@darshankawar darshankawar added plugin: core platform: web Issues / PRs which are specifically for web. and removed Needs Attention This issue needs maintainer attention. triage Issue is currently being triaged. labels Oct 17, 2023
@darshankawar
Copy link

@Codseus
You seem to be hitting same error as #11525 and the potential solution is as mentioned #11525 (comment) that you can try and check if it works in your case or not.
Closing this as a duplicate in favor of the linked issue which is also open currently. If you disagree, write in comments and I'll reopen it.

@darshankawar darshankawar closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2023
@darshankawar darshankawar added the resolution: duplicate This issue or pull request already exists label Oct 18, 2023
@firebase firebase locked and limited conversation to collaborators Nov 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform: web Issues / PRs which are specifically for web. plugin: core resolution: duplicate This issue or pull request already exists type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants