#StackBounty: #firebase #flutter #google-cloud-functions #firebase-tools Run Firebase Callable HTTP Cloud Function locally

Bounty: 50

I’ve a deployed a callable function, say foo, using

firebase deploy --only functions:foo

and I’m calling it in Flutter using:

var result = await FirebaseFunctions.instance.httpsCallable('foo')();
var data = result.data;

All good. But I’d like to run this function in the Firebase Emulator. When I run

firebase emulators:start --only functions

I can see the emulator up and running, and I’m connecting my Flutter app to the emulator using:

FirebaseFunctions.instance.useFunctionsEmulator('localhost', 4000);

However, I don’t know how to invoke the callable foo in Flutter using the Firebase Emulator. I saw this related thread but it doesn’t really answer my question.


Here’s the console output:

✔  functions[us-central1-foo]: http function initialized (http://localhost:5001/my_project/us-central1/foo).

│ ✔  All emulators ready! It is now safe to connect your app. │
│ i  View Emulator UI at http://localhost:4000                │

│ Emulator  │ Host:Port      │ View in Emulator UI             │
│ Functions │ localhost:5001 │ http://localhost:4000/functions │
│ Firestore │ localhost:8080 │ http://localhost:4000/firestore │
  Emulator Hub running at localhost:4400
  Other reserved ports: 4500

I tried

useFunctionsEmulator('localhost', 4000);
useFunctionsEmulator('localhost', 5001);

but both of them throw the following error on calling httpsCallable('foo') but without the emulators, this function does work.

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: [firebase_functions/unavailable] UNAVAILABLE

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.