Firebase-tools: [Error: Internal] when calling a callable cloud function using local emulator

Created on 27 Jan 2020  路  6Comments  路  Source: firebase/firebase-tools

[REQUIRED] Environment info


firebase-tools: 7.12.1


Platform: macOS

[REQUIRED] Test case

  1. Run firebase emulators:start --only functions within ProjectName/functions/
  2. Add
{
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint"
    ],
    "source": "functions"
  },
  "emulators": {
    "functions": {
      "port": 5001
    }
  }
}

To firebase.json

  1. Add app.functions().useFunctionsEmulator('http://localhost:5001'); after initializing firebase app (e.g. const app = firebase.initializeApp(config);)
  2. Disable App Transport Security in info.plist (Building ios app using react-native)
  3. Call callable function from app

[REQUIRED] Steps to reproduce

  1. Create a callable function and call it using the steps from the test case

[REQUIRED] Expected behavior


The app calls the function and the functions returns the expected response with no Internal server error.

[REQUIRED] Actual behavior


[Error: Internal] after making the call to the cloud function. Logs do not output anything. console logging on the first line of the cloud function doesn't output anything, so it doesn't even get inside the function.

However, if I paste the url generated from the emulator into my browser, the emulator does output logs, which tells me that there's something wrong with how the app is calling the function.

Attention

Most helpful comment

@samtstern @JoshLiquornik I found the issue. Since I'm attempting to call the emulated functions on a mobile device, I had to run firebase serve --only functions -o 0.0.0.0 then use app.functions().useFunctionsEmulator('http://<local ip>:<port>');

I just forgot that you can't call localhost functions from other devices....

All 6 comments

@lucasgismondi a few questions:

1) Where does [Error: Internal] show up ... in your iOS app logs?
2) Can you run firebase --debug emulators:start --only functions (notice the --debug flag) and show us the logs from the emulators when the function appears not to be called? There may actually be something going on.

Thank you for prompt reply!

  1. Yes but in my react-native logs. This is my app logs after calling the function. (I'm console logging the error returned from the catch block)
    image

  2. Nothing is being printing in the functions emulator logs using the --debug flag. Here's a screenshot
    image

Same issue here. Any updates on this?

@lucasgismondi sorry but this really is not enough information to figure out what's going wrong here. It seems like the request is never getting from your React Native app to the functions emulator but I don't know at what point it's failing. Error: internal could be coming from any part of the stack.

Are you using RNFirebase? If so I would suggest filing an issue on their repo to see if they can help you trace where the request is failing.

@samtstern @JoshLiquornik I found the issue. Since I'm attempting to call the emulated functions on a mobile device, I had to run firebase serve --only functions -o 0.0.0.0 then use app.functions().useFunctionsEmulator('http://<local ip>:<port>');

I just forgot that you can't call localhost functions from other devices....

Thanks for following up! I've made that same mistake many times.

Was this page helpful?
0 / 5 - 0 ratings