Closed arisAlexis closed 6 months ago
Thanks for the report @arisAlexis
void main() async {
await Helper.loadDotEnv();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
I think await Firebase.initializeApp
has to be the first line inside main()
, but you have await Helper.loadDotEnv();
. Can you reorder and see if it helps ?
commented out the line completely, no difference. First run it logs in the user correctly. Second run that the user is already logged in and this error appears. In the error there is the "authEmulator" wording, I don't understand how is this relevant.
update: it works on production so as it says in the error there is some problem with the authEmulator. There have been many issues with the authEmulator and login/relogin sequences, I think you should prioritize this.
To summarize:
Everything works fine with android/ios emulators and the authEmulator. When I fire up the web I get this error. If I comment out the line to use the authEmulator and it hits production then it works.
Thanks for the update. Keeping this issue open for team's attention and input.
/cc @Lyokone
I think this is relevant #10200
I am also facing the same issue for over two weeks for web. The authEmular is not stable. restarts, log out/login, taskKill for the ports to open, the java.exe remains open, all these make use of the emulator a very painful experience yet it is supposed to help quickly test. Please prioritize. The open java.exe window also hangs and have to click on it, press enter many times for it to wake up.
@Lyokone this is killing everyone developing with emulators and using the web target, pretty significant for adoption imo. Please prioritize.
I discovered a littel secret whenever I face an AuthEmulator error. Assuming all your set ups are ok and it has been working before, I do the following procedure to restart the emulators and they now do pick the web authentication:
netstat -ano | findstr :**_8080_**
(replace the port you are using for the emulator).taskkill /PID **_21222_** /F
(note that the number 21222 is your process ID as shown by running the findstr
command. firebase logout
firebase login
npm install -g firebase-tools
firebase emulators:start
Those steps helps a lot to clean up the whole emulator (you can run the emulator start with other flags e.g. export/import, project etc, like I run it like this: firebase emulators:start --project bwerere-2020 --import=./dir --export-on-exit
and it works now with no issue.
thanks. this is unlikely to help because my problem is very specific. One there is a logged in user and you are using the authEmulator the web crashes. If you are not logged in, it works and it crashes the next time. This can't be a clean up issue.
@Lyokone @darshankawar this is a really big issue for web development that Google is trying to promote. If you can't login with an emulator locally, development is dead. Can you give higher priority?
Have you updated the emulators? i.e. run npm install -g firebase-tools
@russellwheatley yes latest everything new emulators. As I said I think this is relevant https://github.com/firebase/flutterfire/issues/10200. When the user is currently logged in the emulator and you rerun the app then it fails and only for the web.
Same issue ...
Error: Expected a value of type 'firebase_auth.Error', but got one of type 'NativeError'
at await auth.useAuthEmulator('localhost', 9099);
on
void main() async {
WidgetsFlutterBinding.ensureInitialized();
app = await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
auth = FirebaseAuth.instanceFor(app: app);
if (shouldUseFirebaseEmulator) {
await auth.useAuthEmulator('localhost', 9099);
}
runApp(AuthApp());
}
it happens when auth initially was done to firebase server, occasionally or in purpose, and later auth emulator was enabled.
To overcome the issue, signoff should be done first and then emulator works fine.
I am also getting this error suddenly after changing nothing in my app startup in the last 5 months. I have not been able to resolve it. The error only occurs on the emulator and not for cloud instances. Running firebase cli v12.4.3, firebase auth v4.6.3, flutter v3.10.5, and dart 3.0.5.
Error: Expected a value of type 'firebase_auth.Error', but got one of type 'NativeError'
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 288:49 throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 121:3 castError
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart 245:34 as
packages/firebase_auth_web/firebase_auth_web.dart 490:57 useAuthEmulator
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 123:5 _async
packages/firebase_auth_web/firebase_auth_web.dart 466:31 useAuthEmulator
packages/firebase_auth/src/firebase_auth.dart 142:21 useAuthEmulator
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 123:5 _async
packages/firebase_auth/src/firebase_auth.dart 131:31 useAuthEmulator
packages/myth/main.dart 84:33 _startup
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// The last Firebase initialization action should be to check if we're running
// in emulated mode, and if so, use the Firebase emulators instead of the
// cloud database.
if (!environmentVariables.firebaseCloud) {
await FirebaseAuth.instance.useAuthEmulator(remote, 9099); // error throws on this line for web
FirebaseFirestore.instance.useFirestoreEmulator(remote, 8080);
await FirebaseFirestore.instance.clearPersistence();
FirebaseFunctions.instance.useFunctionsEmulator(remote, 5001);
}
runApp(AuthApp());
}
Flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[β] Flutter (Channel stable, 3.10.5, on Microsoft Windows [Version 10.0.22621.1848], locale en-US)
[β] 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 Build Tools 2019 16.11.23)
[β] Android Studio (version 2022.1)
[β] VS Code (version 1.80.0)
[β] Connected device (3 available)
[β] Network resources
β’ No issues found!
Same issue ...
Error: Expected a value of type 'firebase_auth.Error', but got one of type 'NativeError'
at
await auth.useAuthEmulator('localhost', 9099);
onvoid main() async { WidgetsFlutterBinding.ensureInitialized(); app = await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); auth = FirebaseAuth.instanceFor(app: app); if (shouldUseFirebaseEmulator) { await auth.useAuthEmulator('localhost', 9099); } runApp(AuthApp()); }
it happens when auth initially was done to firebase server, occasionally or in purpose, and later auth emulator was enabled.
To overcome the issue, signoff should be done first and then emulator works fine.
Managed to establish the failure path...
Lets hope this issue is not marked as closed before a solution is provided.
@arisAlexis I think this issue was fixed by https://github.com/firebase/flutterfire/pull/10766 and https://github.com/firebase/flutterfire/pull/11247
Testing it locally it looks okay for me. Let me know if you still are reproducing the issue.
Hey @arisAlexis. 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!
Since there haven't been any recent updates here, I am going to close this issue.
@arisAlexis 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.
Bug report
Describe the bug Login is not working after the first user login it crashes.
Error:
The error happens in auth.dart here:
Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
Login
Sample project
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.10.0, on Microsoft Windows [Version 10.0.22621.1702], locale en-US) [β] Windows Version (Installed version of Windows is version 10 or higher) [β] Android toolchain - develop for Android devices (Android SDK version 33.0.2) [β] Chrome - develop for the web [β] Visual Studio - develop for Windows (Visual Studio Build Tools 2022 17.5.4) [β] Android Studio (version 2022.1) [β] Android Studio [β] VS Code (version 1.78.2) [β] Connected device (3 available) [β] Network resources β’ No issues found! ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` βββ audioplayers 3.0.1 β βββ audioplayers_android 2.0.0 β β βββ audioplayers_platform_interface... β β βββ flutter... β βββ audioplayers_darwin 3.0.1 β β βββ audioplayers_platform_interface... β β βββ flutter... β βββ audioplayers_linux 1.0.4 β β βββ audioplayers_platform_interface... β β βββ flutter... β βββ audioplayers_platform_interface 4.0.0 β β βββ flutter... β β βββ plugin_platform_interface... β βββ audioplayers_web 2.2.0 β β βββ audioplayers_platform_interface... β β βββ flutter... β β βββ flutter_web_plugins... β β βββ js... β βββ audioplayers_windows 1.1.3 β β βββ audioplayers_platform_interface... β β βββ flutter... β βββ http 0.13.6 β β βββ async... β β βββ http_parser... β β βββ meta... β βββ flutter... β βββ path_provider... β βββ uuid... βββ cloud_firestore 4.7.0 β βββ cloud_firestore_platform_interface 5.14.0 β β βββ _flutterfire_internals... β β βββ collection... β β βββ firebase_core... β β βββ flutter... β β βββ meta... β β βββ plugin_platform_interface... β βββ cloud_firestore_web 3.5.0 β β βββ _flutterfire_internals... β β βββ cloud_firestore_platform_interface... β β βββ collection... β β βββ firebase_core... β β βββ firebase_core_web... β β βββ flutter... β β βββ flutter_web_plugins... β β βββ js... β βββ collection... β βββ firebase_core... β βββ firebase_core_platform_interface... β βββ flutter... β βββ meta... βββ cloud_functions 4.3.0 β βββ cloud_functions_platform_interface 5.4.0 β β βββ firebase_core... β β βββ flutter... β β βββ meta... β β βββ plugin_platform_interface... β βββ cloud_functions_web 4.5.0 β β βββ cloud_functions_platform_interface... β β βββ firebase_core... β β βββ firebase_core_web... β β βββ flutter... β β βββ flutter_web_plugins... β β βββ js... β βββ firebase_core... β βββ firebase_core_platform_interface... β βββ flutter... βββ cupertino_icons 1.0.5 βββ firebase_analytics 10.4.0 β βββ firebase_analytics_platform_interface 3.6.0 β β βββ _flutterfire_internals... β β βββ firebase_core... β β βββ flutter... β β βββ meta... β β βββ plugin_platform_interface... β βββ firebase_analytics_web 0.5.4 β β βββ _flutterfire_internals... β β βββ firebase_analytics_platform_interface... β β βββ firebase_core... β β βββ firebase_core_web... β β βββ flutter... β β βββ flutter_web_plugins... β β βββ js... β βββ firebase_core... β βββ firebase_core_platform_interface... β βββ flutter... βββ firebase_app_check 0.1.4 β βββ firebase_app_check_platform_interface 0.0.8 β β βββ _flutterfire_internals... β β βββ firebase_core... β β βββ flutter... β β βββ meta... β β βββ plugin_platform_interface... β βββ firebase_app_check_web 0.0.10 β β βββ _flutterfire_internals... β β βββ firebase_app_check_platform_interface... β β βββ firebase_core... β β βββ firebase_core_web... β β βββ flutter... β β βββ flutter_web_plugins... β β βββ js... β βββ firebase_core... β βββ firebase_core_platform_interface... β βββ flutter... βββ firebase_auth 4.6.0 β βββ firebase_auth_platform_interface 6.15.0 β β βββ _flutterfire_internals 1.3.0 β β β βββ collection... β β β βββ firebase_core... β β β βββ firebase_core_platform_interface... β β β βββ flutter... β β β βββ meta... β β βββ collection... β β βββ firebase_core... β β βββ flutter... β β βββ meta... β β βββ plugin_platform_interface... β βββ firebase_auth_web 5.5.0 β β βββ http_parser 4.0.2 β β β βββ collection... β β β βββ source_span... β β β βββ string_scanner... β β β βββ typed_data... β β βββ firebase_auth_platform_interface... β β βββ firebase_core... β β βββ firebase_core_web... β β βββ flutter... β β βββ flutter_web_plugins... β β βββ js... β β βββ meta... β βββ firebase_core... β βββ firebase_core_platform_interface... β βββ flutter... β βββ meta... βββ firebase_core 2.12.0 β βββ firebase_core_platform_interface 4.8.0 β β βββ plugin_platform_interface 2.1.4 β β β βββ meta... β β βββ collection... β β βββ flutter... β β βββ flutter_test... β β βββ meta... β βββ firebase_core_web 2.5.0 β β βββ flutter_web_plugins 0.0.0 β β β βββ characters... β β β βββ collection... β β β βββ flutter... β β β βββ js... β β β βββ material_color_utilities... β β β βββ meta... β β β βββ vector_math... β β βββ firebase_core_platform_interface... β β βββ flutter... β β βββ js... β β βββ meta... β βββ flutter... β βββ meta... βββ firebase_storage 11.2.0 β βββ firebase_storage_platform_interface 4.4.0 β β βββ collection... β β βββ firebase_core... β β βββ flutter... β β βββ meta... β β βββ plugin_platform_interface... β βββ firebase_storage_web 3.6.0 β β βββ _flutterfire_internals... β β βββ async... β β βββ firebase_core... β β βββ firebase_core_web... β β βββ firebase_storage_platform_interface... β β βββ flutter... β β βββ flutter_web_plugins... β β βββ http... β β βββ js... β β βββ meta... β βββ firebase_core... β βββ firebase_core_platform_interface... β βββ flutter... βββ flutter 0.0.0 β βββ characters 1.3.0 β βββ collection 1.17.1 β βββ js 0.6.7 β β βββ meta... β βββ material_color_utilities 0.2.0 β βββ meta 1.9.1 β βββ sky_engine 0.0.99 β βββ vector_math 2.1.4 βββ flutter_dotenv 5.0.2 β βββ flutter... βββ flutter_easyloading 3.0.5 β βββ flutter_spinkit 5.2.0 β β βββ flutter... β βββ flutter... βββ flutter_facebook_auth 5.0.11 β βββ facebook_auth_desktop 0.0.9 β β βββ flutter_secure_storage 8.0.0 β β β βββ flutter_secure_storage_linux 1.1.3 β β β β βββ flutter... β β β β βββ flutter_secure_storage_platform_interface... β β β βββ flutter_secure_storage_macos 3.0.0 β β β β βββ flutter... β β β β βββ flutter_secure_storage_platform_interface... β β β βββ flutter_secure_storage_platform_interface 1.0.1 β β β β βββ flutter... β β β β βββ plugin_platform_interface... β β β βββ flutter_secure_storage_web 1.1.1 β β β β βββ flutter... β β β β βββ flutter_secure_storage_platform_interface... β β β β βββ flutter_web_plugins... β β β β βββ js... β β β βββ flutter_secure_storage_windows 2.0.0 β β β β βββ flutter... β β β β βββ flutter_secure_storage_platform_interface... β β β βββ flutter... β β β βββ meta... β β βββ flutter... β β βββ flutter_facebook_auth_platform_interface... β β βββ http... β βββ flutter_facebook_auth_platform_interface 4.1.1 β β βββ flutter... β β βββ plugin_platform_interface... β βββ flutter_facebook_auth_web 4.1.1 β β βββ flutter... β β βββ flutter_facebook_auth_platform_interface... β β βββ flutter_web_plugins... β β βββ js... β βββ flutter... βββ flutter_image_compress 1.1.3 β βββ flutter... βββ flutter_lints 2.0.1 β βββ lints 2.1.0 βββ flutter_login 4.1.1 β βββ another_flushbar 1.12.30 β β βββ flutter... β βββ another_transformer_page_view 2.0.1 β β βββ flutter... β βββ quiver 3.2.1 β β βββ matcher... β βββ sign_in_button 3.2.0 β β βββ flutter... β β βββ font_awesome_flutter... β βββ flutter... β βββ font_awesome_flutter... β βββ provider... β βββ url_launcher... βββ flutter_test 0.0.0 β βββ boolean_selector 2.1.1 β β βββ source_span... β β βββ string_scanner... β βββ clock 1.1.1 β βββ fake_async 1.3.1 β β βββ clock... β β βββ collection... β βββ matcher 0.12.15 β β βββ async... β β βββ meta... β β βββ stack_trace... β β βββ term_glyph... β β βββ test_api... β βββ path 1.8.3 β βββ source_span 1.9.1 β β βββ collection... β β βββ path... β β βββ term_glyph... β βββ stack_trace 1.11.0 β β βββ path... β βββ string_scanner 1.2.0 β β βββ source_span... β βββ term_glyph 1.2.1 β βββ test_api 0.5.1 β β βββ async... β β βββ boolean_selector... β β βββ collection... β β βββ matcher... β β βββ meta... β β βββ source_span... β β βββ stack_trace... β β βββ stream_channel... β β βββ string_scanner... β β βββ term_glyph... β βββ async... β βββ characters... β βββ collection... β βββ flutter... β βββ js... β βββ material_color_utilities... β βββ meta... β βββ stream_channel... β βββ vector_math... βββ flutter_webrtc 0.9.29+hotfix.1 β βββ dart_webrtc 1.0.16 β β βββ platform_detect 2.0.7 β β β βββ pub_semver 2.1.4 β β β β βββ collection... β β β β βββ meta... β β β βββ meta... β β βββ js... β β βββ webrtc_interface... β βββ webrtc_interface 1.0.13 β βββ collection... β βββ flutter... β βββ js... β βββ path_provider... βββ font_awesome_flutter 10.4.0 β βββ flutter... βββ image_picker 0.8.7+5 β βββ image_picker_android 0.8.6+14 β β βββ flutter_plugin_android_lifecycle 2.0.14 β β β βββ flutter... β β βββ flutter... β β βββ image_picker_platform_interface... β βββ image_picker_for_web 2.1.12 β β βββ flutter... β β βββ flutter_web_plugins... β β βββ image_picker_platform_interface... β βββ image_picker_ios 0.8.7+4 β β βββ flutter... β β βββ image_picker_platform_interface... β βββ image_picker_platform_interface 2.6.3 β β βββ cross_file 0.3.3+4 β β β βββ js... β β β βββ meta... β β βββ flutter... β β βββ http... β β βββ plugin_platform_interface... β βββ flutter... βββ path_provider 2.0.15 β βββ path_provider_android 2.0.27 β β βββ flutter... β β βββ path_provider_platform_interface... β βββ path_provider_foundation 2.2.3 β β βββ flutter... β β βββ path_provider_platform_interface... β βββ path_provider_linux 2.1.10 β β βββ ffi 2.0.2 β β βββ xdg_directories 1.0.0 β β β βββ process 4.2.4 β β β β βββ file... β β β β βββ path... β β β β βββ platform... β β β βββ meta... β β β βββ path... β β βββ flutter... β β βββ path... β β βββ path_provider_platform_interface... β βββ path_provider_platform_interface 2.0.6 β β βββ platform 3.1.0 β β βββ flutter... β β βββ plugin_platform_interface... β βββ path_provider_windows 2.1.6 β β βββ win32 4.1.4 β β β βββ ffi... β β βββ ffi... β β βββ flutter... β β βββ path... β β βββ path_provider_platform_interface... β βββ flutter... βββ provider 6.0.5 β βββ nested 1.0.0 β β βββ flutter... β βββ collection... β βββ flutter... βββ rflutter_alert 2.0.4 β βββ flutter... βββ shared_preferences 2.1.1 β βββ shared_preferences_android 2.1.4 β β βββ flutter... β β βββ shared_preferences_platform_interface... β βββ shared_preferences_foundation 2.2.2 β β βββ flutter... β β βββ shared_preferences_platform_interface... β βββ shared_preferences_linux 2.2.0 β β βββ file 6.1.4 β β β βββ meta... β β β βββ path... β β βββ flutter... β β βββ path... β β βββ path_provider_linux... β β βββ path_provider_platform_interface... β β βββ shared_preferences_platform_interface... β βββ shared_preferences_platform_interface 2.2.0 β β βββ flutter... β β βββ plugin_platform_interface... β βββ shared_preferences_web 2.1.0 β β βββ flutter... β β βββ flutter_web_plugins... β β βββ shared_preferences_platform_interface... β βββ shared_preferences_windows 2.2.0 β β βββ file... β β βββ flutter... β β βββ path... β β βββ path_provider_platform_interface... β β βββ path_provider_windows... β β βββ shared_preferences_platform_interface... β βββ flutter... βββ url_launcher 6.1.11 β βββ url_launcher_android 6.0.33 β β βββ flutter... β β βββ url_launcher_platform_interface... β βββ url_launcher_ios 6.1.4 β β βββ flutter... β β βββ url_launcher_platform_interface... β βββ url_launcher_linux 3.0.5 β β βββ flutter... β β βββ url_launcher_platform_interface... β βββ url_launcher_macos 3.0.5 β β βββ flutter... β β βββ url_launcher_platform_interface... β βββ url_launcher_platform_interface 2.1.2 β β βββ flutter... β β βββ plugin_platform_interface... β βββ url_launcher_web 2.0.16 β β βββ flutter... β β βββ flutter_web_plugins... β β βββ url_launcher_platform_interface... β βββ url_launcher_windows 3.0.6 β β βββ flutter... β β βββ url_launcher_platform_interface... β βββ flutter... βββ uuid 3.0.7 β βββ crypto 3.0.3 β βββ typed_data 1.3.2 β βββ collection... βββ web_socket_channel 2.4.0 βββ async 2.11.0 β βββ collection... β βββ meta... βββ stream_channel 2.1.1 β βββ async... βββ crypto... ```