firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.02k stars 937 forks source link

Firebase emulators shows CREATE REQUEST as Allowed but nothing happens/gets updated #7613

Closed MirzaCickusic closed 1 month ago

MirzaCickusic commented 2 months ago

[REQUIRED] Environment info

13.15.4

macOS

[REQUIRED] Test case

Cant provide example, this should be straight forward functionality of updating firestore emulator DB

[REQUIRED] Steps to reproduce

  1. I'm testing this via flutter app - flutter version:
    Flutter 3.24.1 • channel stable •
    https://github.com/flutter/flutter.git
    Framework • revision 5874a72aa4 (10 days ago) • 2024-08-20
    16:46:00 -0500
    Engine • revision c9b9d5780d
    Tools • Dart 3.5.1 • DevTools 2.37.2
  2. Trying to update/create an user in Users collection:

    static final FirebaseFirestore _firestore = FirebaseFirestore.instance;
    
    Future<void> userSetup(UserModel user) async {
    return users.doc(user.uid).set({
      'uid': user.uid,
      'email': user.email,
      'preferredCategories': user.preferredCategories,
      'createdAt': user.createdAt,
    }).catchError((error) => FirebaseCrashlytics.instance
        .log('Error when creating new user: $error. Uid: ${user.uid}'));
    }
  3. Firebase emulator started with:
    firebase emulators:start --only firestore,storage,auth --project local-test-app --import ./local_testing_firebase_state --export-on-exit
  4. My flutter app is pointing to the emulator:

    FirebaseFirestore firestore = FirebaseFirestore.instance;
    FirebaseAuth auth = FirebaseAuth.instance;
    FirebaseFunctions functions = FirebaseFunctions.instance;
    FirebaseStorage storage = FirebaseStorage.instance;
    
    // Pointing the Firebase services to the emulator
    // Uncomment and adjust the ports as per your emulator setup
    await storage.useStorageEmulator('localhost', 9095);
    await auth.useAuthEmulator('localhost', 9099);
    functions.useFunctionsEmulator('localhost', 9098);
    firestore.useFirestoreEmulator('localhost', 9097);
    firestore.clearPersistence();

[REQUIRED] Expected behavior

Firestore Users collection gets updated and new document are added. My code works on DEV and PROD firebase instances.

[REQUIRED] Actual behavior

Nothing happens inside firestore except that it shows that request had come:image

But the Users collection is not showing the UID's mentioned in the requests:

image
google-oss-bot commented 2 months ago

This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

aalej commented 2 months ago

Hey @MirzaCickusic, thanks for reaching out. It’s odd that the documents are not being created in the Firestore emulator even though the request tab shows that a request has been made.

Currently, I’m unable to reproduce this behavior. I created this repo to try and replicate this, when running the app, I was able to create a Firestore document in the emulator. If I’m missing anything here, please let me know. Also, by any chance, could you provide a minimal reproducible example to help us narrow down what could’ve caused this issue?

Lastly, which platform are you running your application on(e.g., Android, Web, or iOS)? If you’re running on multiple platforms, are you able to reproduce the issue on all platforms or only specific ones?

aalej commented 2 months ago

Just discussed this with our engineering team, we think the issue here might be with the Emulator UI. The document might actually be getting created, and it's possible that it's not showing up in the Emulator UI. Could you try:

  1. Opening a fresh Emulator UI page then navigate to the Firestore tab.
  2. Open your browser's Developer Tool and check the Network and Console tabs.
  3. Try to create a new document using your app.

Are there any error logs shown in the Console tab or are any of the new requests in the Network tab resulting in errors? For the latter, could you share with us your HAR file so that we can check the failing requests?

google-oss-bot commented 1 month ago

Hey @MirzaCickusic. 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 3 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 1 month ago

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

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