firebase-tools-ui icon indicating copy to clipboard operation
firebase-tools-ui copied to clipboard

No collection/docs visible in firestore emulator, but data exists

Open rublev opened this issue 3 years ago • 12 comments

image

If I manually create the "scraper/categories" collection/document then it works fine, but initially the UI is just blank.

Any reasons why? I already tried firebase --project="project" emulators:start in the commandline along with putting the project id in the "initializeApp" function but nothing works to initially show me the data. This is data imported locally from my live database. It all works fine and it's all there I just have to manually create the initial path every time.

rublev avatar Jan 19 '21 19:01 rublev

Just to clarify, what do you mean by "just blank"? Is it totally blank or stuck on loading screen? Or is it showing a functional Firestore view, but with no collections in it?

Are you using the latest Firebase CLI build? Please double check the version number and refresh the page after update. If things still don't work, please kindly generate an HAR file from your browser and upload it.

yuchenshi avatar Jan 19 '21 22:01 yuchenshi

Just to clarify, what do you mean by "just blank"? Is it totally blank or stuck on loading screen? Or is it showing a functional Firestore view, but with no collections in it?

Are you using the latest Firebase CLI build? Please double check the version number and refresh the page after update. If things still don't work, please kindly generate an HAR file from your browser and upload it.

I'm using latest everything. In the emulator the root documents are missing, I have to always create the root collection manually and then everything else shows up. It's showing a functional firestore view, with no collections in it (despite the documents existing as my frontend fetches them locally/in prod just fine).

rublev avatar Jan 26 '21 23:01 rublev

I'm having the same problem here

marcopandolfo avatar Jan 29 '21 17:01 marcopandolfo

I have been struggling with this same problem for some days, looks like it connects somewhere, but not the right localhost firestore

lucasmarinzeck avatar Jan 29 '21 18:01 lucasmarinzeck

Can report the same, came to open a bug report and found it :) Screenshot 2021-02-08 at 15 29 52 Screenshot 2021-02-08 at 15 29 45

JoeEarly avatar Feb 08 '21 15:02 JoeEarly

@JoeEarly Thanks for the screenshot! This seems to narrow the problem down to the Firestore Emulator, where we're seeing 503 (Service Unavailable) -- that's something new.

For anyone experiencing this, would you mind attaching your firestore-debug.log when this happens again? (FYI It's firestore-debug, which will likely contain the stack trace of that error in the Java process of Firestore Emulator.)

yuchenshi avatar Feb 24 '21 18:02 yuchenshi

Is anyone still experiencing this problem? Any chance to grab the firestore-debug.log for us to troubleshoot?

yuchenshi avatar Jun 10 '21 21:06 yuchenshi

#566 is one cause of this

j0hnsmith avatar Oct 01 '21 14:10 j0hnsmith

#566

I have the same error only when loading a DB dump from our prod Firestore, it was working fine until a few days ago, now it only loads blank in the emulator UI. The data is there as I can still query it all, just the UI is not loading it.

The emulator logs keep throwing errors like:

logger.ts:115 [2022-06-20T22:27:25.891Z]  @firebase/firestore: Firestore (8.8.1): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.

image

MorenoMdz avatar Jun 20 '22 22:06 MorenoMdz

#566

I have the same error only when loading a DB dump from our prod Firestore, it was working fine until a few days ago, now it only loads blank in the emulator UI. The data is there as I can still query it all, just the UI is not loading it.

The emulator logs keep throwing errors like:

logger.ts:115 [2022-06-20T22:27:25.891Z]  @firebase/firestore: Firestore (8.8.1): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.

image

Similar issue on my end except even if I manually create a document, it just doesn't show up.

polymer-coder avatar Sep 04 '22 13:09 polymer-coder

oops! the problem was the name of my project in the firebase config was spelled wrong by one dinky character. so I thought I was using the exact same project name when running the emulator and inside my project but I was wrong. so it is working for me now.

I'm having the same issue. Have tried many different things but nothing works. Data exists in my app but not shown in the emulator. Have tried:

  • Set environment variable export FIRESTORE_EMULATOR_HOST=127.0.0.1:8080
  • npx firebase use demo-.... before starting the emulator; created the alias first
  • Config for my app is the exact same for real vs emulator, except the projectId is demo-...
  • singleProjectMode as false
  • Tried Clear All Data button
  • Tried export on exit and import
  • Incognito mode, different browsers
  • Make sure ports configured correctly

My log file...

Feb 09, 2023 4:17:38 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start
INFO: Started WebSocket server on ws://127.0.0.1:9150
API endpoint: http://127.0.0.1:8080
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

   export FIRESTORE_EMULATOR_HOST=127.0.0.1:8080

Dev App Server is now running.

Feb 09, 2023 4:18:02 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler initChannel
INFO: Connected to new websocket client
Feb 09, 2023 4:18:41 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
Multiple projectIds are not recommended in single project mode. Requested project ID demo-hotkey-pro, but the emulator is configured for demo-hotkeys-pro. This warning will become an error in the future. To opt-out of single project mode add/set the '"single_project_mode": false' property in the firebase.json emulators config.
Feb 09, 2023 4:18:41 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
Feb 09, 2023 4:18:41 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
Feb 09, 2023 4:18:47 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler initChannel
INFO: Connected to new websocket client
Feb 09, 2023 4:18:47 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
Feb 09, 2023 4:18:47 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler channelClosed
INFO: Websocket client disconnected
Feb 09, 2023 4:18:47 PM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler initChannel
INFO: Connected to new websocket client
Feb 09, 2023 4:18:47 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected HTTP/2 connection.

How to debug this?

jmagaram avatar Feb 10 '23 00:02 jmagaram

For me, I had the exact same symptoms.. data existed but wasn't visible in the UI. It was because of my app context.

tldr; You need to pass your initialized app to firestore when you instantiate it

The Fix

I changed my code from

initialize_app()
db = firestore.Client()

to

app = initialize_app()
db = firestore.Client(app.project_id)

More info:

It was caused by this error which I saw when I ran firestore emulators:start --debug

[2023-06-01T18:26:26.857Z] Multiple projectIds are not recommended in single project mode. Requested project ID google-cloud-firestore-emulator, but the emulator is configured for my-project-id. To opt-out of single project mode add/set the '"singleProjectMode": false' property in the firebase.json emulators config.

berengamble avatar Jun 01 '23 19:06 berengamble