We've been using the emulators for a while now. Suddenly, they stopped working on the machines of two developers (but not all developers). They attempt to invoke firebase emulators:start and are then treated to the following error message: Error: An unexpected error has occurred.
We really have no idea why this is happening. We even tried redoing firebase init and emulators init. So far nothing we have tried has helped. Here is the console output for more detail:
➜ firebase git:(dev-vab) ✗ firebase emulators:start
i emulators: Starting emulators: functions, firestore, database, hosting, pubsub
⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth
⚠ Your requested "node" version "10" doesn't match your global version "14"
i firestore: Firestore Emulator logging to firestore-debug.log
i database: Database Emulator logging to database-debug.log
i hosting: Serving hosting files from: public
✔ hosting: Local server: http://0.0.0.0:5000
i pubsub: Pub/Sub Emulator logging to pubsub-debug.log
i ui: Emulator UI logging to ui-debug.log
i functions: Watching "/Users/isaacmartin/git_repos/firebase/functions" for Cloud Functions...
✔ functions[updateUser]: firestore function initialized.
✔ functions[handleEventInviteeCreation]: http function initialized (http://0.0.0.0:5001/likemindedly-stage/us-central1/handleEventInviteeCreation).
i emulators: Shutting down emulators.
i ui: Stopping Emulator UI
⚠ Emulator UI has exited upon receiving signal: SIGINT
i functions: Stopping Functions Emulator
i hosting: Stopping Hosting Emulator
i database: Stopping Database Emulator
i firestore: Stopping Firestore Emulator
i pubsub: Stopping Pub/Sub Emulator
i hub: Stopping emulator hub
i logging: Stopping Logging Emulator
Error: An unexpected error has occurred.
Having trouble? Try again or contact support with contents of firebase-debug.log
Now, you will note that we did check the debug log and found the following, which may be related:
[debug] [2020-10-22T22:06:39.394Z] 15:06:39.394 [FirebaseWorkerPool-1-2] WARN com.firebase.core.namespace.NamespaceActorSystem - Request for ns: likemindedly-stage has incorrect domain. Current domain: 0.0.0.0, expected domain: firebaseio-staging.com
{"metadata":{"emulator":{"name":"database"},"message":"15:06:39.394 [FirebaseWorkerPool-1-2] WARN com.firebase.core.namespace.NamespaceActorSystem - Request for ns: likemindedly-stage has incorrect domain. Current domain: 0.0.0.0, expected domain: firebaseio-staging.com\n"}}
[debug] [2020-10-22T22:06:39.448Z] <<< HTTP RESPONSE 404 {"content-length":"231","content-type":"application/json; charset=utf-8","access-control-allow-origin":"*","cache-control":"no-cache"}
[debug] [2020-10-22T22:06:39.448Z] <<< HTTP RESPONSE BODY {
"correctUrl" : "https://likemindedly-stage.firebaseio-staging.com",
"error" : "Namespace likemindedly-stage lives in a different region. Please change your database URL to https://likemindedly-stage.firebaseio-staging.com"
}
It seems to be complaining that we are pointing at local emulators in our config, though, it's not clear why this would be a problem?
I also encountered this issue starting just a few hours ago. It allowed me to start the emulators as normal when I removed the hosts from my firebase.json, but I haven't figured out what exactly is causing the error or how to set the hosts properly outside of the json file.
Another way to solve this problem is to add the new firebase auth emulator to your emulator suite.
Related
My firebase functions express app is not allowing me to call it when emulating.
The emulator seems to be running fine:
The logs in a better format:
i emulators: Starting emulators: functions
⚠ hub: Error when trying to check port 4400 on ::1: Error: listen EADDRNOTAVAIL: address not available ::1:4400
⚠ hub: Port 4400 is available on 127.0.0.1 but not ::1. This may cause issues with some clients.
⚠ hub: If you encounter connectivity issues, consider switching to a different port or explicitly specifying "host": "<ip address>" instead of hostname in firebase.json
⚠ logging: Error when trying to check port 4500 on ::1: Error: listen EADDRNOTAVAIL: address not available ::1:4500
⚠ logging: Port 4500 is available on 127.0.0.1 but not ::1. This may cause issues with some clients.
⚠ logging: If you encounter connectivity issues, consider switching to a different port or explicitly specifying "host": "<ip address>" instead of hostname in firebase.json
⚠ eventarc: Error when trying to check port 9299 on ::1: Error: listen EADDRNOTAVAIL: address not available ::1:9299
⚠ eventarc: Port 9299 is available on 127.0.0.1 but not ::1. This may cause issues with some clients.
⚠ eventarc: If you encounter connectivity issues, consider switching to a different port or explicitly specifying "host": "<ip address>" instead of hostname in firebase.json
⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, firestore, database, hosting, pubsub, storage
✔ functions: Using node#16 from host.
i ui: Emulator UI logging to ui-debug.log
i functions: Watching "/app/functions" for Cloud Functions...
⚠ functions: package.json indicates an outdated version of firebase-functions. Please upgrade using npm install --save firebase-functions#latest in your functions directory.
⚠ functions: Please note that there will be breaking changes when you upgrade.
✔ functions: Loaded functions definitions from source: .
The emulator UI:
The code:
import * as functions from "firebase-functions"
import * as admin from "firebase-admin"
import express, { Express } from "express"
const bodyParser = require("body-parser")
const cors = require("cors")
const routes = require("./routes")
if (admin.apps.length === 0) {
admin.initializeApp()
}
const app: Express = express()
app.use(cors({ origin: true }))
app.use("/api/v2", routes)
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
exports.app = functions.region("europe-west1").https.onRequest(app)
Calling http://0.0.0.0:8087/MY-PROJECT-NAME/europe-west1/app/api/v2 and any subsquent route produces the error message:
Function europe-west1-app does not exist, valid functions are: and then no valid functions.
My emulator is in a docker container with port mappings 8087:8080 (hence the above URL).
I have tried a number of combinations for the endpoint to no avail. I am clearly missing something.
What am I doing wrong?
Routes look like:
router.get("/", centre.hello) // This one return a hello string that I've been using to troubleshoot. no luck
router.post("/centre/add", centre.addCentre)
Edited to add additional logs as requested
I'm an idiot.
Although I had exported "app" as above, I had not provided an index.ts which I believe firebase needed.
I realised this when I deployed the functions live and the error message was a lot more helpful.
Emulators now work as expected
I have a firebase project where I invited a developer as an owner. He got email and accepted the invitation. Yet he can't deploy functions to that project. He also tried with different internet connections. It's failing with the error below....
! functions: Upload Error: Server Error. read ECONNRESET
Error: Server Error. read ECONNRESET
firebase-debug.log
[debug] [2020-05-13T23:49:33.202Z] >>> HTTP REQUEST PUT https://storage.googleapis.com/gcf-upload-us-central1....
<request body omitted>
[warn] ! functions: Upload Error: Server Error. read ECONNRESET
[debug] [2020-05-13T23:49:55.186Z] Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:111:27)
[error]
[error] Error: Server Error. read ECONNRESET
index.js file contains a simple function that was generated automatically by firebase init command.This is what index.js file contains..
const functions = require("firebase-functions");
exports.helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
});
There was a problem with the google api link in my country. For some reason, these google API were blocked here.
Started firebase project emulators (which uses cloud functions and firestore) with below command
firebase emulators:start
It runs successfully and gives me a path to connect to the functions and shows a local host url for firestore too.
Then, to execute my jest tests, ran the below command
firebase emulators:exec --only firestore jest
As per the documentation, to connect to local firstore, we need to use exec. But its throwing below error.
i emulators: Starting emulators: firestore
⚠ emulators: emulator hub unable to start on port 4400, starting on 4401
✔ hub: emulator hub started at http://localhost:4401
i Shutting down emulators.
i Stoppping emulator hub
⚠ Port 8080 is not open on localhost, could not start firestore emulator.
i To select a different host/port for the emulator, update your "firebase.json":
{
// ...
"emulators": {
"firestore": {
"host": "HOST",
"port": "PORT"
}
}
}
i Shutting down emulators.
Error: Could not start firestore emulator, port taken.
This error is thrown everytime when I run exec command. Can someone point out what could be wrong?
Edit: Logs from firebase emulators:start
firebase emulators:start
i emulators: Starting emulators: functions, firestore, hosting, pubsub
✔ hub: emulator hub started at http://localhost:4400
⚠ Your requested "node" version "8" doesn't match your global version "10"
✔ functions: functions emulator started at http://localhost:5001
i firestore: Serving ALL traffic (including WebChannel) on http://localhost:8080
⚠ firestore: Support for WebChannel on a separate port (8081) is DEPRECATED and will go away soon. Please use port above instead.
i firestore: firestore emulator logging to firestore-debug.log
✔ firestore: firestore emulator started at http://localhost:8080
i firestore: For testing set FIRESTORE_EMULATOR_HOST=localhost:8080
i hosting[website]: Serving hosting files from: public
✔ hosting[website]: Local server: http://localhost:5000
i hosting[admin]: Serving hosting files from: public
✔ hosting[admin]: Local server: http://localhost:5005
i hosting[b2b]: Serving hosting files from: public
✔ hosting[b2b]: Local server: http://localhost:5006
i hosting[b2c]: Serving hosting files from: public
✔ hosting[b2c]: Local server: http://localhost:5007
i hosting[sdk]: Serving hosting files from: public
✔ hosting[sdk]: Local server: http://localhost:5008
✔ hosting: hosting emulator started at http://localhost:5000
i pubsub: pubsub emulator logging to pubsub-debug.log
✔ pubsub: pubsub emulator started at http://localhost:8085
Update
With a fresh start also the mentioned error is shown. But killing the port made it work.
Added below in scipts part of package.json
"kill": "npx kill-port 5000 5001 8080 8085 4000 9229"
and run
npm run kill
Here all above listed ports aren't reqired. Just 8080 might work in your case but I have other ports too being used by the emulator.
lsof command is not availalble on windows powershell.
A better cross-platform solution is: npx kill-port 8080
Type this in your terminal, where 8080 is your port number:
lsof -ti tcp:8080 | xargs kill
Reason: Failed quitting the previous firebase emulator.
There is an issue filed for firepit (the standalone CLI installable with curl): #1868
Installing it as Node package may help: npm install -g firebase-tools
If this should already be the case, you probably should file an issue there.
I closed the terminal, then opened it again, launched command again and it works
I am trying to deploy my angular app to firebase, I have tried all methods to init firebase, select hosting and then deploying my app on firebase from various tutorials. But I always get an error:
I don't know what's wrong .
This is how my firebase-debug.log looks
[debug] [2020-03-26T10:42:00.096Z] ----------------------------------------------------------------------
[debug] [2020-03-26T10:42:00.098Z] Command: C:\Program Files\nodejs\node.exe C:\Users\pulki\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js deploy
[debug] [2020-03-26T10:42:00.098Z] CLI Version: 7.16.1
[debug] [2020-03-26T10:42:00.098Z] Platform: win32
[debug] [2020-03-26T10:42:00.098Z] Node Version: v10.16.3
[debug] [2020-03-26T10:42:00.099Z] Time: Thu Mar 26 2020 16:12:00 GMT+0530 (India Standard Time)
[debug] [2020-03-26T10:42:00.099Z] ----------------------------------------------------------------------
[debug] [2020-03-26T10:42:00.099Z]
[debug] [2020-03-26T10:42:00.105Z] > 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"]
[debug] [2020-03-26T10:42:00.105Z] > authorizing via signed-in user
[debug] [2020-03-26T10:42:00.105Z] [iam] checking project frezzo-pul5 for permissions ["firebase.projects.get","firebasedatabase.instances.update","firebasehosting.sites.update"]
[debug] [2020-03-26T10:42:00.108Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2020-03-26T10:42:00.108Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token
<request body omitted>
[debug] [2020-03-26T10:42:00.624Z] <<< HTTP RESPONSE 200
[debug] [2020-03-26T10:42:00.630Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/frezzo-pul5:testIamPermissions
[debug] [2020-03-26T10:42:02.770Z] <<< HTTP RESPONSE 200
[debug] [2020-03-26T10:42:02.772Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/frezzo-pul5
[debug] [2020-03-26T10:42:03.760Z] <<< HTTP RESPONSE 200
[info]
[info] === Deploying to 'frezzo-pul5'...
[info]
[info] i deploying database, hosting
[info] i database: checking rules syntax...
[debug] [2020-03-26T10:42:03.764Z] >>> HTTP REQUEST PUT https://frezzo-pul5.firebaseio.com/.settings/rules.json?dryRun=true
{
"rules": {
".read": true,
".write": true
}
}
[debug] [2020-03-26T10:42:06.330Z] <<< HTTP RESPONSE 404
[debug] [2020-03-26T10:42:06.330Z] <<< HTTP RESPONSE BODY {
"error" : "Firebase error. Please ensure that you spelled the name of your Firebase correctly"
}
[error]
[error] Error: Unexpected error while deploying database rules.
I have set no security on my firebase Database. Is that an issue ?
I have also tried firebase serve to locally check my app and that just works fine.
Thanks for you help !!
If you deactivated one or more of the functions since activation, when running
$ firebase init for the first time, it will mess up things when trying to deploy.
For example, sometimes realtime databases get automatically deactivated if you are not using them, just try to re-enable them to be able to deploy. Otherwise, you'll need to re-run the init with different options, and remove unused files for it to work.
Try initiating the firebase database from console. In most cases, the firebase database is not set on the cloud, so the console utility is not able to upload the db rules, and hence gives this error. Try using the following commands:
firebase init database
following updates will follow on the console:
=== Database Setup
i database: ensuring required API firebasedatabase.googleapis.com is enabled...
⚠ database: missing required API firebasedatabase.googleapis.com. Enabling now...
✔ database: required API firebasedatabase.googleapis.com is enabled
? It seems like you haven’t initialized Realtime Database in your project yet. Do you want to set it up? Yes
? Please choose the location for your default Realtime Database instance: us-central1
✔ Creating your default Realtime Database instance: ********-default-rtdb
With this, your database deployment error might get resolved.
I have previously been able to successfully deploy my static site. Now it hangs and tells me I need to re-authenticate, even though I appear to be authenticated.
$ firebase -V
3.9.0
$ firebase login
Already logged in as <>
$ firebase deploy
⚠ Your CLI authentication needs to be updated to take advantage of new features.
⚠ Please run firebase login --reauth
Other firebase commands just hang. I tried
$ firebase list --debug
and it hangs on
>>> HTTP REQUEST GET https://admin.firebase.com/v1/projects
Until eventually I get
Error: connect ETIMEDOUT 104.197.85.31:443
at Object.exports._errnoException (util.js:1050:11)
at exports._exceptionWithHostPort (util.js:1073:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1093:14)
Error: Server Error. connect ETIMEDOUT 104.197.85.31:443
Any ideas?
Turns out it was a networking/firewall issue blocking access on port 443.