1
votes

When trying to use the cloud functions emulator, I get a message stating:

function ignored because the firestore emulator does not exist or is not running

I have tried mentioned here: (Firestore/Firebase Emulator Not Running).

My functions/package.json looks like this:

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "eslint .",
    "serve": "firebase serve --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "8"
  },
  "dependencies": {
    "firebase-admin": "^8.0.0",
    "firebase-functions": "^3.1.0"
  },
  "devDependencies": {
    "eslint": "^5.12.0",
    "eslint-plugin-promise": "^4.0.1",
    "firebase-functions-test": "^0.1.6"
  },
  "private": true
}

Command I'm using to start the emulator:

    firebase emulators:start --only functions

This is the output I'm getting:

i  Starting emulators: ["functions"]
!  Your requested "node" version "8" doesn't match your global version "10"
+  functions: Emulator started at http://localhost:5001
i  functions: Watching "C:\Users\MyName\Documents\MyProject\functions" for Cloud Functions...
i  functions[updateFunction]: function ignored because the firestore emulator does not exist or is not running.
+  All emulators started, it is now safe to connect.

I am doing a console.log in the function but I don't see it on the port (5001).

Any help would be appreciated.

2
I don't understand what the problem is. Please edit the question to show the code of the function, how you are invoking it, and explain what's not working the way you expect. - Doug Stevenson
The function itself is not relevant. Let's just say it's doing a console log. The function runs and I see the console log when it's deployed. It is trigged when I write to a database from my app that uses a firestore database. I'm trying to run the function in the emulator. I assume the log should come out on the emulator port (5001) when the function is triggered but it's not. It does get triggered because I see the log in the firebase console (just not on the emulator port). I think this is related to the "function ignored because the firestore emulator...." print. That's the problem. - ak22
Following up, I realized one thing. Since I was only starting the functions emulator and not the firestore emulator, the print in question is referring to the firestore emulator. So I started all the emulators and now I don't see the print. So, now the question is do the updates to the firestore also need to be "emulated" updates rather than real updates in order for the "emulated" functions to get triggered? - ak22

2 Answers

3
votes

If you want to trigger a Firestore function, you will need to make that change in the local Firestore emulator. Locally emulated functions don't respond to actual cloud-hosted databases. The emulation on all products must be local.

0
votes
functions[updateFunction]: function ignored because the firestore emulator does not exist or is not running.

Maybe the 'updateFunction' is the handler function for watching a change of your firestore documents, isn't it?

So you might need to start firestore at the same time with functions.

Just execute without --only option with the firebase.json configurations

{
  "hosting": {
    "public": "public",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
  },
  "functions": {
    "source": "functions"
  },
  "emulators": {
    "functions": {
      "port": 5001
    },
    "firestore": {
      "port": 8080
    },
    "hosting": {
      "port": 5000
    },
    "ui": {
      "enabled": true,
      "host": "localhost",
      "port": 4000
    }
  }
}

And if you want to connect your server-side functions with your IDE for debugging, you need '--inspect-functions' option, or you just have to check logs in the emulator log page "http://localhost:4000/logs"

firebase emulators:start --inspect-functions