question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

[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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
lucasgismondicommented, Feb 4, 2020

@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…

0reactions
samtsterncommented, Feb 4, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

FirebaseError:Internal Given While Testing Callable Firebase ...
I am trying to test a callable Firebase cloud function using a Node.js script using the functions emulator, but I keep getting the...
Read more >
Call functions from your app | Cloud Functions for Firebase
To use HTTPS callable functions you must use the client SDK for your ... client instead receives an error with the message INTERNAL...
Read more >
Cloud Functions | React Native Firebase
Using an emulator. Whilst developing your application with Cloud Functions, it is possible to run the functions inside of a local emulator. To...
Read more >
Using Cloud Functions for Firebase - FlutterFire
If you are using the local Cloud Functions emulators, then it is possible to connect to these using the useFunctionsEmulator method. Ensure you...
Read more >
Troubleshooting Cloud Functions - Google Cloud
Make sure you specify the name of your function correctly. You can always check using gcloud functions call which returns the correct 404...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found