Firebase-tools: Serve command does not change Firestore Emulator port with --port flag

Created on 21 May 2019  Â·  11Comments  Â·  Source: firebase/firebase-tools

I didn't see anything in the --help mentioning otherwise, I was trying to pass the --port argument with the serve command for only firestore and it seems firestore always uses the default port of 8080.

[REQUIRED] Environment info


firebase-tools: 6.10.0


Platform: Ubuntu 18.04

[REQUIRED] Test case

firebase serve --only firestore --port 9090

[REQUIRED] Steps to reproduce

$ firebase serve --only firestore --port 9090
i firestore: Logging to firestore-debug.log
✔ firestore: Emulator started at http://localhost:8080

[REQUIRED] Expected behavior


Emulator starts on port 9090

[REQUIRED] Actual behavior

Emulator starts on port 8080

[2019-05-21T17:22:00.102Z] ----------------------------------------------------------------------
[2019-05-21T17:22:00.104Z] Command:       /snap/node/2023/bin/node /usr/local/bin/firebase serve --only firestore --port 9090 --debug
[2019-05-21T17:22:00.105Z] CLI Version:   6.10.0
[2019-05-21T17:22:00.105Z] Platform:      linux
[2019-05-21T17:22:00.105Z] Node Version:  v10.15.3
[2019-05-21T17:22:00.105Z] Time:          Tue May 21 2019 10:22:00 GMT-0700 (Pacific Daylight Time)
[2019-05-21T17:22:00.105Z] ----------------------------------------------------------------------

[2019-05-21T17:22:00.111Z] Starting emulator firestore with args {"port":8080}
i  firestore: Logging to firestore-debug.log
✔  firestore: Emulator started at http://localhost:8080
[2019-05-21T17:22:00.824Z] API endpoint: http://[::1]:
[2019-05-21T17:22:00.825Z] 8080

[2019-05-21T17:22:00.830Z] API endpoint: http://
[2019-05-21T17:22:00.830Z] 127.0.0.1:8080

[2019-05-21T17:22:00.831Z] If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

[2019-05-21T17:22:00.832Z] 
   export FIRESTORE_EMULATOR_HOST=[::1]:8080,127.0.0.1:8080

Dev App Server is now running.
emulator-suite firestore

Most helpful comment

I think we should add a warning message to firebase serve --only firestore and recommend the new emulators:start command.

All 11 comments

Unfortunately, the --port flag for firebase serve only affects the hosting emulator.

The new recommended way of running the Firestore emulator is via the firebase emulators:start command. This command will read from your firebase.json, and you can configure the behavior of the emulators there. For instance, one of my projects has this:

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "emulators": {
    "firestore": {
      "port": 1234
    }
  }
}

and when I run firebase emulators:start --only firestore I get

> firebase emulators:start --only firestore
i  Starting emulators: ["firestore"]
i  firestore: Logging to firestore-debug.log
✔  firestore: Emulator started at http://localhost:1234

I think we should add a warning message to firebase serve --only firestore and recommend the new emulators:start command.

@ryanpbrewster is this a regression? It was for functions and I fixed it with https://github.com/firebase/firebase-tools/pull/1267

I agree we should add a warning to people "serving" the Firestore/RTDB emulators but if this is a regression I think I could fix it pretty easily.

not a regression, this has always been the Firestore emulator behavior

if it's easy to fix it might be nice to use the --port value if there's only one emulator supplied

eenteresting @ryanpbrewster ...very good to know about the firebase.json emulator config options

After talking to the team, we are going to move away from firebase serve for anything besides hosting and functions (since it was originally build for those) and therefore encourage those who want to start the Firestore emulator on a specific port to use the emulators:start command in conjunction with firebase.json config.

To hold up our end of the bargain, we plan to have greatly expanded docs soon so that these options are not hidden.

ok, cool.

@samtstern
One question regarding your comment to move away from firebase serve:

How is this supposed to work on CI systems as the firebase emulators requires authentication but firebase serve --only firestore does not. We tried using the generated firebase login:ci token but for some reason we get random quota limit responses (it also requires an authenticated firebase use run which I don't really understand as it should not talk to google API at all on CI).

Is this then being worked on that firebase emulators: also does not require any authentication?

@pschneider we are making some progress on this (see #1437) so that you can at least start the Firestore and RTDB emulators without authentication. The functions emulator will be a little trickier.

it happens with the emulators:start command.

It happens even when explicitly specifying a new port in the firebase.json.

Was this page helpful?
0 / 5 - 0 ratings