-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
First, I'm posting a broader API design question that might make this bug relevant or not:
Is there a particular reason why _fromJsUser and _fromJsUserInfo are not considering whether the input parameter is null? There is a pretty obvious use case in which this is true, which I'll describe in the bug below.
Describe the bug
onAuthStateChange stream throws an uncaught error when user is not authenticated (firebase.User is null).
To Reproduce
Steps to reproduce the behavior:
- Initialize at least one subscription to
FirebaseAuth.instance.onAuthStateChangedstream. - Run the application on web platform (i.e.
flutter run -d chrome) - In case the user is not authenticated or authentication status changes to that state, the console will output the following exception and your subscription(s) won't be triggered:
firebase_auth_web.dart:46 Uncaught (in promise) TypeError: Cannot read property 'providerId' of null
at firebase_auth_web.FirebaseAuthWeb.new.[_fromJsUser] (firebase_auth_web.dart:46)
at _MapStream.new.[_handleData] (stream_pipe.dart:229)
at _ForwardingStreamSubscription.new.[_handleData] (stream_pipe.dart:166)
at _RootZone.runUnaryGuarded (zone.dart:1316)
at _BroadcastSubscription.new.[_sendData] (stream_impl.dart:338)
at _BroadcastSubscription.new.[_add] (stream_impl.dart:265)
at _SyncBroadcastStreamController.new.[_sendData] (broadcast_stream_controller.dart:377)
at _SyncBroadcastStreamController.new.add (broadcast_stream_controller.dart:252)
at auth.dart:307
at Object._checkAndCall (operations.dart:326)
at Object.dcall (operations.dart:331)
at Object.ret [as next] (js_dart2js.dart:531)
at subscribe.ts:104
at subscribe.ts:233Expected behavior
onAuthStateChanged stream should trigger another event with null as the value of the observed FirebaseUser parameter.
Additional context
I'll edit this if there is additional questions in the comments.
For now, here's flutter doctor and flutter --version:
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.12.13+hotfix.6, on Mac OS X 10.14.6 18G1012, locale en-RS)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.41.0)
[✓] Connected device (3 available)
• No issues found!
$ flutter --version
Flutter 1.12.13+hotfix.6 • channel beta • https://github.com/flutter/flutter.git
Framework • revision 18cd7a3601 (9 days ago) • 2019-12-11 06:35:39 -0800
Engine • revision 2994f7e1e6
Tools • Dart 2.7.0EDIT1: Here's the relevant line that's calling the _fromJsUser with null input param.