7

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.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Eli Himself
  • 834
  • 3
  • 8
  • 20

4 Answers4

6

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.

Fanchen Bao
  • 3,310
  • 1
  • 21
  • 34
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.

Eli Himself
  • 834
  • 3
  • 8
  • 20
  • This happens when working with Flutter as well. And your solution doesn't work for me, unfortunately. – Loolooii Mar 26 '22 at 10:05
0

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.

Dan Sterrett
  • 1,160
  • 11
  • 12
0

From my end, the versions are updated in functions that will affect UI and firebase functions:shell.

Here I updated npm i firebase-tools with latest version like npm install -g firebase-tools@11.14.0. Then restart the emulator, it working fine now.

Meena Arumugam
  • 134
  • 3
  • 11