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

Firestore emulator can access the UI, but nothing happens when interacting with it

Open TDAK1509 opened this issue 3 years ago • 11 comments

Issue:

I tried to run firestore on emulator but failed to interact with it.

Reproduce:

$ firebase --version
9.23.0

$ mkdir test

$ cd test

$ firebase init emulators
> choose Don't set up a default project
> choose Firestore emulator
--> Choose default for every next option

$ cat firebase.json
{
  "emulators": {
    "firestore": {
      "port": 8080
    },
    "ui": {
      "enabled": true
    }
  }
}
$ firebase emulators:start --project test
i  emulators: Starting emulators: firestore
⚠  firestore: Did not find a Cloud Firestore rules file specified in a firebase.json config file.
⚠  firestore: The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration.
i  firestore: Firestore Emulator logging to firestore-debug.log
i  ui: Emulator UI logging to ui-debug.log

┌─────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is now safe to connect your app. │
│ i  View Emulator UI at http://localhost:4000                │
└─────────────────────────────────────────────────────────────┘

┌───────────┬────────────────┬─────────────────────────────────┐
│ Emulator  │ Host:Port      │ View in Emulator UI             │
├───────────┼────────────────┼─────────────────────────────────┤
│ Firestore │ localhost:8080 │ http://localhost:4000/firestore │
└───────────┴────────────────┴─────────────────────────────────┘
  Emulator Hub running at localhost:4400
  Other reserved ports: 4500

Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.

Go to the page http://localhost:4000/firestore/data and create a document. After clicking SAVE, nothing happens.

image


Updated

Running with debug flag

firebase emulators:start --project test --debug
[2022-10-14T01:06:30.022Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2022-10-14T01:06:30.023Z] > authorizing via signed-in user ([email protected])
i  emulators: Starting emulators: firestore {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: firestore"}}
[2022-10-14T01:06:30.036Z] [hub] writing locator at /var/folders/dd/p17lp6xs4370kp88pqbdx_8r0000gn/T/hub-test.json
⚠  firestore: Did not find a Cloud Firestore rules file specified in a firebase.json config file. {"metadata":{"emulator":{"name":"firestore"},"message":"Did not find a Cloud Firestore rules file specified in a firebase.json config file."}}
⚠  firestore: The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration. {"metadata":{"emulator":{"name":"firestore"},"message":"The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration."}}
[2022-10-14T01:06:30.053Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: projectId"}}
[2022-10-14T01:06:30.053Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[2022-10-14T01:06:30.054Z] Starting Firestore Emulator with command {"binary":"java","args":["-Dgoogle.cloud_firestore.debug_log_level=FINE","-Duser.language=en","-jar","/Users/tdak/.cache/firebase/emulators/cloud-firestore-emulator-v1.13.1.jar","--host","localhost","--port",8080],"optionalArgs":["port","webchannel_port","host","rules","functions_emulator","seed_from_export"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {\"binary\":\"java\",\"args\":[\"-Dgoogle.cloud_firestore.debug_log_level=FINE\",\"-Duser.language=en\",\"-jar\",\"/Users/tdak/.cache/firebase/emulators/cloud-firestore-emulator-v1.13.1.jar\",\"--host\",\"localhost\",\"--port\",8080],\"optionalArgs\":[\"port\",\"webchannel_port\",\"host\",\"rules\",\"functions_emulator\",\"seed_from_export\"],\"joinArgs\":false}"}}
i  firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
[2022-10-14T01:06:31.022Z] Oct 14, 2022 8:06:31 AM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start
INFO: Started WebSocket server on ws://localhost:58177
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:06:31 AM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start\nINFO: Started WebSocket server on ws://localhost:58177\n"}}
[2022-10-14T01:06:31.042Z] API endpoint: http://localhost:8080 {"metadata":{"emulator":{"name":"firestore"},"message":"API endpoint: http://localhost:8080"}}
[2022-10-14T01:06:31.043Z]
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

   export FIRESTORE_EMULATOR_HOST=localhost:8080

Dev App Server is now running.

 {"metadata":{"emulator":{"name":"firestore"},"message":"\nIf you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:\n\n   export FIRESTORE_EMULATOR_HOST=localhost:8080\n\nDev App Server is now running.\n\n"}}
⚠  ui: Emulator UI unable to start on port 4000, starting on 4001 instead. {"metadata":{"emulator":{"name":"ui"},"message":"Emulator UI unable to start on port 4000, starting on 4001 instead."}}
[2022-10-14T01:06:31.089Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: auto_download"}}
[2022-10-14T01:06:31.089Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: port"}}
[2022-10-14T01:06:31.090Z] Starting Emulator UI with command {"binary":"node","args":["/Users/tdak/.cache/firebase/emulators/ui-v1.6.4/server.bundle.js"],"optionalArgs":[],"joinArgs":false} {"metadata":{"emulator":{"name":"ui"},"message":"Starting Emulator UI with command {\"binary\":\"node\",\"args\":[\"/Users/tdak/.cache/firebase/emulators/ui-v1.6.4/server.bundle.js\"],\"optionalArgs\":[],\"joinArgs\":false}"}}
i  ui: Emulator UI logging to ui-debug.log {"metadata":{"emulator":{"name":"ui"},"message":"Emulator UI logging to \u001b[1mui-debug.log\u001b[22m"}}
[2022-10-14T01:06:31.182Z] Web / API server started at localhost:4001
 {"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at localhost:4001\n"}}

┌─────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is now safe to connect your app. │
│ i  View Emulator UI at http://localhost:4001                │
└─────────────────────────────────────────────────────────────┘

┌───────────┬────────────────┬─────────────────────────────────┐
│ Emulator  │ Host:Port      │ View in Emulator UI             │
├───────────┼────────────────┼─────────────────────────────────┤
│ Firestore │ localhost:8080 │ http://localhost:4001/firestore │
└───────────┴────────────────┴─────────────────────────────────┘
  Emulator Hub running at localhost:4400
  Other reserved ports: 4500

Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.

Debug messages after creating a document

[2022-10-14T01:07:16.381Z] Oct 14, 2022 8:07:16 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:16 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-10-14T01:07:16.423Z] Oct 14, 2022 8:07:16 AM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler initChannel
INFO: Connected to new websocket client
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:16 AM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketChannelHandler initChannel\nINFO: Connected to new websocket client\n"}}
[2022-10-14T01:07:16.476Z] Oct 14, 2022 8:07:16 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:16 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-10-14T01:07:16.588Z] Oct 14, 2022 8:07:16 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:16 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected HTTP/2 connection.\n"}}
[2022-10-14T01:07:20.178Z] Oct 14, 2022 8:07:20 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:20 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-10-14T01:07:22.199Z] Oct 14, 2022 8:07:22 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:22 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-10-14T01:07:24.220Z] Oct 14, 2022 8:07:24 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:24 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-10-14T01:07:26.241Z] Oct 14, 2022 8:07:26 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:26 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-10-14T01:07:28.265Z] Oct 14, 2022 8:07:28 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:28 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-10-14T01:07:30.283Z] Oct 14, 2022 8:07:30 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:30 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-10-14T01:07:32.298Z] Oct 14, 2022 8:07:32 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:32 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-10-14T01:07:34.244Z] Oct 14, 2022 8:07:34 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:34 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-10-14T01:07:34.315Z] Oct 14, 2022 8:07:34 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:34 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-10-14T01:07:34.366Z] Oct 14, 2022 8:07:34 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:34 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-10-14T01:07:36.338Z] Oct 14, 2022 8:07:36 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:36 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}
[2022-10-14T01:07:38.362Z] Oct 14, 2022 8:07:38 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected non-HTTP/2 connection.
 {"metadata":{"emulator":{"name":"firestore"},"message":"Oct 14, 2022 8:07:38 AM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead\nINFO: Detected non-HTTP/2 connection.\n"}}

TDAK1509 avatar Nov 23 '21 12:11 TDAK1509

I am having the same issue. Did you find a solution?

jorgemndoza avatar Jun 17 '22 20:06 jorgemndoza

Same issue here

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

I am having the same issue. Did you find a solution?

No solution so far...

TDAK1509 avatar Sep 06 '22 02:09 TDAK1509

@TDAK1509 I've opened a similar issue here: https://github.com/firebase/firebase-tools-ui/issues/854

polymer-coder avatar Sep 06 '22 07:09 polymer-coder

Hi all, there's no obvious reproducible case here. When starting the emulators can you include the --debug flag for more information?

christhompsongoogle avatar Oct 14 '22 00:10 christhompsongoogle

Hi all, there's no obvious reproducible case here. When starting the emulators can you include the --debug flag for more information?

@christhompsongoogle Updated with debug messages

TDAK1509 avatar Oct 14 '22 01:10 TDAK1509

@TDAK1509 Did you find a solution?

jorgemndoza avatar Nov 10 '22 16:11 jorgemndoza

Is this still happening on the latest version?

Random note, FirestoreEmulatedApiProvider isn't searchable here: https://cs.opensource.google/search?q=f:FirestoreEmulatedApiProvider&ss=firebase-sdk%2Ffirebase-tools-ui

but exists here: https://github.com/firebase/firebase-tools-ui/blob/308a98d9a7b0dc3aba3228f701a01719fd3cb870/src/components/Firestore/FirestoreEmulatedApiProvider.tsx

christhompsongoogle avatar Nov 10 '22 22:11 christhompsongoogle

I was facing the same issue this week.

It turned out, that I miss-formatted my firestore-rules with the latest changes and therefore the firestore emulator was not functinable.

==> I found the error in the firestore-debug.log

Hope this is helping for someone else.


Would be great, when the emulator would show such an error in the ui or in the logs at least. But from now on I will be looking into the debug logs a little bit earlier xD

AKretsche avatar Nov 13 '22 12:11 AKretsche

AKretsche, do you have a repro case we can look at?

christhompsongoogle avatar Nov 17 '22 20:11 christhompsongoogle

Hi @christhompsongoogle can be reproduce by creating a syntax error in the firestore.rules, like deleting an if statement:

  • allow write: if false
  • 🐞 allow write: false

Now the firestore emulator is not creating any collection or document anymore.

When the emulator is still running while saving the lokal rules, the error will be printed in the console logs:

⚠ firestore.rules:43:22 - ERROR Missing 'if' before conditional expression.

But when you are starting the emulator with such an error in the rules, you will not get any error prompted in the console or in the emulator UI.

instead the error is logged in the firestore-debug.log, which is good, but maybe hard to find when the emulator is not reacting properly and you are not expecting an error in the rules.

AKretsche avatar Nov 17 '22 22:11 AKretsche