Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emulator functionality is not clear and causes auth errors which look like bugs #1299

Closed
j-gj opened this issue May 16, 2019 · 12 comments
Closed
Assignees

Comments

@j-gj
Copy link

j-gj commented May 16, 2019

[REQUIRED] Environment info

firebase-tools: 6.9.2

in package.json
"firebase-admin": "^7.3.0",
"firebase-functions": "^2.3.1",

Platform: macOS

[REQUIRED] Test case

I'm trying to test my functions locally using the guide listed here.
https://firebase.google.com/docs/functions/local-emulator

I have 37 functions (mostly Firestore, but some RTDB, some Storage, 1 HTTP and 1 Auth) and they all work perfectly when deploying to the cloud environment. But when I deploy locally major errors happen and only the HTTP Function seems to (initially) work. See additional errors below when trying to ping the HTTP function.

[REQUIRED] Steps to reproduce

I have installed the latest firebase-tools using

npm install -g firebase-tools

In my package.json I confirmed to be running

"firebase-admin": "^7.3.0",
"firebase-functions": "^2.3.1",

I've initialized my admin using the below.

const admin = require('firebase-admin');
admin.initializeApp()

When I try to run my functions using

firebase emulators:start

[REQUIRED] Expected behavior

Not have a ton of errors.

[REQUIRED] Actual behavior

Starting the emulator

JG-MBP-15:cloud-functions USER$ firebase emulators:start
i Starting emulators: ["functions"]
⚠ Your requested "node" version "8" doesn't match your global version "11"
✔ functions: Emulator started at http://localhost:5001
i functions: Watching "/Users/USER/Documents/PROJECT/cloud-functions/functions" for Cloud Functions...
⚠ Default "firebase-admin" instance created!

---start express---
[2019-05-16T01:05:46.951Z] @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND"."}
[2019-05-16T01:05:47.376Z] @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND"."}
⚠ Ignoring trigger "FUNCTION" because the service "firebaseauth.googleapis.com" is not yet supported.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the service "firebaseio.com" is not yet supported.
⚠ Ignoring trigger "FUNCTION" because the service "firebaseio.com" is not yet supported.
⚠ Ignoring trigger "FUNCTION" because the service "firebaseio.com" is not yet supported.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the Cloud Firestore emulator is not running.
⚠ Ignoring trigger "FUNCTION" because the service "storage.googleapis.com" is not yet supported.
⚠ Ignoring trigger "FUNCTION" because the service "storage.googleapis.com" is not yet supported.
i functions: HTTP trigger initialized at http://localhost:5001/PROJECT/us-central1/FUNCTIONXYZ
[2019-05-16T01:05:47.703Z] @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND"."}
[2019-05-16T01:05:48.755Z] @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND"."}
[2019-05-16T01:05:49.149Z] @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND"."}
[2019-05-16T01:05:50.077Z] @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND"."}
[2019-05-16T01:05:53.364Z] @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND"."}

When I try to ping the HTTP Function ("FUNCTIONXYZ") it results in the below error

i functions: Beginning execution of "FUNCTIONXYZ"
⚠ Default "firebase-admin" instance created!
⚠ The Cloud Firestore emulator is not running so database operations will fail with a 'default credentials' error.
⚠ The Cloud Firestore emulator is not running so database operations will fail with a 'default credentials' error.
⚠ The Cloud Firestore emulator is not running so database operations will fail with a 'default credentials' error.
⚠ The Cloud Firestore emulator is not running so database operations will fail with a 'default credentials' error.

---start express---
[2019-05-16T01:18:29.787Z] @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND"."}
[2019-05-16T01:18:29.835Z] @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND"."}
i functions: Finished "FUNCTIONXYZ" in ~1s

@google-oss-bot
Copy link
Contributor

This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

@samtstern
Copy link
Contributor

Hmmm ok something is way off here. First could you try running "firebase init firestore" and then starting the emulators again?

@j-gj
Copy link
Author

j-gj commented May 16, 2019

I did notice that when running through the various documentation that firestore wasn't there when other places reference it https://firebase.google.com/docs/cli#initialize_a_firebase_project

The firebase init firestore helped me create a firestore.rules and firestore.indexes.json file that I didn't have before

However when I go to run firebase emulators:start it gives me the below popup to install Java, even though it's installed?

JG-MBP-15:cloud-functions USER$ firebase emulators:start
i  Starting emulators: ["functions","firestore"]
⚠  Your requested "node" version "8" doesn't match your global version "11"
✔  functions: Emulator started at http://localhost:5001
i  firestore: Logging to firestore-debug.log
✔  firestore: Emulator started at http://localhost:8080

Error: firestore: emulator has exited with code: 

Screen Shot 2019-05-15 at 6 46 26 PM

Screen Shot 2019-05-15 at 6 46 56 PM

@j-gj
Copy link
Author

j-gj commented May 16, 2019

Realized that was just a JRE. Going to get the JDK 8u211 from https://www.oracle.com/technetwork/java/javase/downloads/index.html and report back

@j-gj
Copy link
Author

j-gj commented May 16, 2019

After installing the JDK, I'm getting

NOTE I replaced actual function names with "FUNCTION"

JG-MBP-15:cloud-functions USER$ firebase emulators:start
i  Starting emulators: ["functions","firestore"]
⚠  Your requested "node" version "8" doesn't match your global version "11"
✔  functions: Emulator started at http://localhost:5001
i  firestore: Logging to firestore-debug.log
✔  firestore: Emulator started at http://localhost:8080
i  firestore: For testing set FIREBASE_FIRESTORE_EMULATOR_ADDRESS=localhost:8080
i  functions: Watching "/Users/USER/Documents/cloud-functions/functions" for Cloud Functions...
⚠  Default "firebase-admin" instance created!
>  ---start express---
>  [2019-05-16T02:12:35.348Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
⚠  Ignoring trigger "FUNCTION" because the service "firebaseauth.googleapis.com" is not yet supported.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
>  [2019-05-16T02:12:35.916Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
>  [2019-05-16T02:12:37.091Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
⚠  Ignoring trigger "FUNCTION" because the service "firebaseio.com" is not yet supported.
⚠  Ignoring trigger "FUNCTION" because the service "firebaseio.com" is not yet supported.
⚠  Ignoring trigger "FUNCTION" because the service "firebaseio.com" is not yet supported.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
>  [2019-05-16T02:12:38.712Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
i  functions: Setting up Cloud Firestore trigger "FUNCTION"
✔  functions: Trigger "FUNCTION" has been acknowledged by the Cloud Firestore emulator.
⚠  Ignoring trigger "FUNCTION" because the service "storage.googleapis.com" is not yet supported.
⚠  Ignoring trigger "FUNCTION" because the service "storage.googleapis.com" is not yet supported.
i  functions: HTTP trigger initialized at http://localhost:5001/[hostname]/us-central1/shopify
>  [2019-05-16T02:12:40.119Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
>  [2019-05-16T02:12:40.308Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
>  [2019-05-16T02:12:43.498Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
>  [2019-05-16T02:12:45.739Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
>  [2019-05-16T02:12:50.097Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
>  [2019-05-16T02:12:51.471Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
>  [2019-05-16T02:12:58.476Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
>  [2019-05-16T02:13:06.258Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
>  [2019-05-16T02:13:08.278Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
>  [2019-05-16T02:13:30.835Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."} 
>  [2019-05-16T02:13:36.407Z]  @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."}

@j-gj
Copy link
Author

j-gj commented May 16, 2019

I've also tried generating my own service account keys and initializing using

var serviceAccount = require("../../../../path/FILENAME.json");
 admin.initializeApp({
     credential: admin.credential.cert(serviceAccount),
     databaseURL: "https://PROJECT.firebaseio.com"
 });

And it seems to work a little better, but my functions don't work still. Trying to trigger my HTTP function locally gives me an error, but using the cloud deployed function it responds normally.

I generated the keys using the below. Let me know if I should use firebase-adminsdk credentials.

the PROJECTNAME@appspot.gserviceaccount.com that has App Engine default service account credentials

NOT

firebase-adminsdk-CODE@PROJECTNAME.iam.gserviceaccount.com with firebase-adminsdk credentials

JG-MBP-15:cloud-functions USER$ firebase emulators:start
i Starting emulators: ["functions","firestore"]
⚠ Your requested "node" version "8" doesn't match your global version "11"
✔ functions: Emulator started at http://localhost:5001
i firestore: Logging to firestore-debug.log
✔ firestore: Emulator started at http://localhost:8080
i firestore: For testing set FIREBASE_FIRESTORE_EMULATOR_ADDRESS=localhost:8080
i functions: Watching "/Users/USER/Documents/cloud-functions/functions" for Cloud Functions...

initializing with local service account
⚠ Default "firebase-admin" instance created!
---start express---
⚠ Ignoring trigger "FUNC" because the service "firebaseauth.googleapis.com" is not yet supported.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
⚠ Ignoring trigger "FUNC" because the service "firebaseio.com" is not yet supported.
⚠ Ignoring trigger "FUNC" because the service "firebaseio.com" is not yet supported.
⚠ Ignoring trigger "FUNC" because the service "firebaseio.com" is not yet supported.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
i functions: Setting up Cloud Firestore trigger "FUNC"
✔ functions: Trigger "FUNC" has been acknowledged by the Cloud Firestore emulator.
⚠ Ignoring trigger "FUNC" because the service "storage.googleapis.com" is not yet supported.
⚠ Ignoring trigger "FUNC" because the service "storage.googleapis.com" is not yet supported.
i functions: HTTP trigger initialized at http://localhost:5001/PROJECT/us-central1/FUNC

@abeisgoat
Copy link
Contributor

abeisgoat commented May 16, 2019

This is actually more of a documentation / logging issue than anything else.

There is a split in functionality, between running your code via serve and emulators:start which isn't well documented. If you want to simply invoke your code and with it, access production APIs and services, similar to the classic Google Cloud Function emulator, then your code should be invoked with serve. When you invoke your functions via emulators:start we do everything we can to prevent you from accidentally contacting production services. As we flesh out the emulator functionality, this mode will become more and more powerful, but right now it can look broken (we're planning on adding more helpful errors soon). For the current releases our focus is on maintaining backwards compatibility with the old GCF emulator via serve and all the cool things we're planning for emulators:start are largely still WIP.

You were able to work around this the sandboxing by providing a service account because the protection we currently offer is done by removing application default credentials from the environment, when you supplied them directly that safeguard no longer functioned.

In a future release, you'll be able to pass a flag to get into an unsafe emulator mode where you'll be able to access anything you like, but we haven't passed the CLI flags or firebase.json file changes though our internal review yet, so they don't exist.

In regards to your HTTPS function throwing an error, that's a separate issue, if the function you're attempting to invoke is an Express app, then that was a known issue which will be patched in 6.9.3, if that's not the case, then please provide specific data about what's the fail looks like and we'll dig in.

@abeisgoat abeisgoat self-assigned this May 16, 2019
@abeisgoat abeisgoat changed the title Firebase Emulators Not Running / Credentials Failing Emulator functionality is not clear and causes auth errors which look like bugs May 16, 2019
@j-gj
Copy link
Author

j-gj commented May 16, 2019

Hmmmm yes the HTTP function is using an Express app. The endpoint/API works fine in cloud environment but fails on local emulation. Will see if it works on 6.9.3. Any idea on when that might be?

(realized you released 6.9.2 only 5 days ago so appreciate all the help)
https://www.npmjs.com/package/firebase-tools?activeTab=versions

@abeisgoat
Copy link
Contributor

Yes it should work in 6.9.3 I specifically patched that situation. The new version will go out by the end of the week.

Thanks for testing stuff and helping us work out all the issues! We'll get this thing to be useful soon :)

@abeisgoat
Copy link
Contributor

Closing this in favor of tracking error improvements in #1310

@grrrian
Copy link

grrrian commented Nov 28, 2019

@abeisgoat Is there a way to run emulated cloud functions (firebase emulators:start --only functions) but still use the real database? I would like to avoid emulating firestore.

When I do, I get a bunch of errors: ⚠ The Cloud Firestore emulator is not running so database operations will fail with a 'default credentials' error.

@samtstern
Copy link
Contributor

@grrrian you're doing it right, are you on the latest version of firebase-tools? That error message looks old to me, and it's something we changed earlier this year.

If you update to the latest version then you can do exactly what you wanted: running --only functions means that requests to Firestore will go to production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants