firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.58k stars 3.94k forks source link

[firebase_auth] authStateChanges() stream fires when read/write into firestore #13057

Closed lethanhclub closed 2 weeks ago

lethanhclub commented 1 month ago

Is there an existing issue for this?

Which plugins are affected?

Auth

Which platforms are affected?

Web

Description

My flutter sdk: Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale en-VN) [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.4) [✓] Chrome - develop for the web [✓] Android Studio (version 2024.1) [✓] VS Code (version 1.91.0) [✓] Connected device (3 available) [✓] Network resources

• No issues found!

authStateChanges() always fires 2 events (waiting and active) when I read/write data into firestore.

Reproducing the issue

1# Open the web app - I call this FirebaseAuth.instance.setPersistence(Persistence.LOCAL) in main, I also use AppCheck. 1.1 authStateChanges fires waiting event -> I show loading indicator 1.2 authStateChanges fires active event -> I got logged-in user, then I show home screen 2# I read the list of profiles in home screen, then I see the web app reload because authStateChanges fires 2 events like 1# 2.1 authStateChanges fires waiting event 2.2 authStateChanges fires active event 3# I go to profile screen from home screen. I update some properties of that profile, then authStateChanges fires 2 events like 1# 3.1 authStateChanges fires waiting event 3.2 authStateChanges fires active event

Firebase Core version

3.1.1

Flutter Version

3.22.2

Relevant Log Output

No response

Flutter dependencies

Expand Flutter dependencies snippet
```yaml Replace this line with the contents of your `flutter pub deps -- --style=compact`. ```

Additional context and comments

No response

TarekkMA commented 1 month ago

@lethanhclub Thank you for reporting this issue. Can you please provide a complete minimal example following the guidelines here: Minimal Reproducible Example?

google-oss-bot commented 1 month ago

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

lethanhclub commented 1 month ago

@lethanhclub Thank you for reporting this issue. Can you please provide a complete minimal example following the guidelines here: Minimal Reproducible Example?

sorry I have a question.

I have to paste code here or upload a small project?

lethanhclub commented 1 month ago

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

which information do you need?

russellwheatley commented 1 month ago

@lethanhclub - Ideally a repository, but we can work with a code sample, please ensure it is the smallest code sample you can provide without the need for external dependencies that demonstrates the bug.

google-oss-bot commented 3 weeks ago

Hey @lethanhclub. 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 commented 2 weeks ago

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

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