0

I used to run the following command to run some tests against a emulated firestore instance:

firebase emulators:exec --only firestore 'npm test'

Since my upgrade to "firebase-functions": "^3.18.0" and `"firebase-functions-test": "^0.3.3"' this doesn't execute my tests anymore. And after a minute gives me: Error: TIMEOUT: Port 8080 on localhost was not active within 60000ms

Running firebase emulators:start --only firestore works fine. And if I change the command above to firebase emulators:exec --only auth 'npm test' the execution works as expected, but obviously the tests fail.

Does anyone have an idea on how to solve this?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
dfinki
  • 324
  • 4
  • 13

2 Answers2

1

As Gourav B asked me what node version I was on. I figured I would try to run it with different versions I had installed.

Version 17 was the default one, and would still not work. I quickly changed to 14 and the firebase emulators:exec --only firestore 'npm test' would run smoothly.

Also node version 16 doesn't have any problems.

As a tip to people reading this: To quickly switch between node versions I personally use Node Version Manager (nvm)

dfinki
  • 324
  • 4
  • 13
0

The reason for receiving this error in Firebase emulators might be due to a number of reasons. I would try to bring out all the possible solutions to resolve this through this answer.

  • Extend the duration of your Cloud Functions. Follow this.
  • You may try specifying the host as "127.0.0.1" instead of the default ‘localhost’. Firebase.json should look like this:
  { 
    "Firestore":
     { 
      "rules": "firestore.rules", 
      "indexes": "firestore.indexes.json"
     },
   "Emulators":
     { 
       "Firestore":
          { 
            "port": 8080, 
            "host": "127.0.0.1"
          }, 
      "Ui":
          { 
           "enabled": true
          }
       }
    }

  • Sometimes, reverting back to the previous version fixes, as suggested in the Stackoverflow case.
  • You could try running the Firestore emulator JAR directly and see if it works for you.
Mousumi Roy
  • 609
  • 1
  • 6
  • thanks for answering! as explained: firestore runs but the emulators:exec command doesn't run the specified script after starting firestore. due to emulators:exec the firestore-emulator waits for a minute and then exits, because no requests (from the script) have been made. – dfinki Feb 16 '22 at 09:23
  • You may have a look at this [Stackoverflow case](https://stackoverflow.com/questions/60996172/unable-to-connect-to-firebase-emulator-suite-with-exec). Let me know if that helps! – Mousumi Roy Feb 16 '22 at 11:21
  • it was because I was running it with node version 17. The command doesn't seem to work there yet. node 16 and below worked. Thanks for answering! – dfinki Feb 18 '22 at 15:54