'Firebase Firestore Emulator UI is not showing any data, but data is being returned in app query

I am facing an odd issue with firebase's firestore emulator. When i start the emulator, and check the emulator's firestore UI, it shows that no data exists in the db yet.

Then, i try query the firestore emulator for data from my react-native app and surprisingly, old data from previous session comes back. I am being returned data i added in a previous session, yet it is not visible on the emulator UI.

I was under the impression that shutting down the emulator removes any data added during that session so, when starting the emulator next time why am i seeing data from my previous session? Its as if its being cached somehow somewhere...?

I have seen multiple posts on stack-overflow about the --project parameter being supplied to firebase emulators:start terminal command. This seems to make no difference whatsoever to my case.

I would appreciate any suggestions on resolving.



Solution 1:[1]

Turns out, firebase native version has some sort of caching mechanism that acts a bit odd.

The solution that worked for me was, i deleted the app i was developing from the emulator/device and made sure i hit "delete all app data" if prompted.

After that, i would install fresh and the firebase would act just fine as expected.

Solution 2:[2]

From my experience, one must match the project the app is connected to with the project Firebase CLI is currently using. Otherwise, the Firestore Emulator UI does not show live interaction with the app.

To be specific, the Firebase project whose google-service.json or GoogleService-Info.plist files are being used by the app must match the project currently being used in the output of firebase projects:list.

If the two projects do not match, the app can still connect to the emulator; data read and write also work; but the live Firestore Emulator UI won't show anything.

Solution 3:[3]

My problem was caused by the emulator UI running on two different ports. The port I was viewing was from an older process that hadn't shut down properly.

Switch to the "Logs" tab, and see if there is a message similar to

Emulator UI unable to start on port 4000, starting on 4003 instead.

If so, make sure you are viewing the emulator on port 4003 and not 4000 (in this example) or kill the old process running on port 4000, and restart the emulator.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eli Himself
Solution 2 Fanchen Bao
Solution 3 Dan Sterrett