I'm trying to call a very simple cloud function from my Flutter app following the FlutterFire docs, but I'm getting a pretty unreadable error. The error occurs whether I'm using the emulators, or attempting to call the function fully deployed with Firebase.
My cloud function code:
import * as functions from "firebase-functions";
export const ping = functions.https.onCall(() => ({ ping: "pong" }));
And my Flutter code in main.dart:
import 'package:cloud_functions/cloud_functions.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:my_app/firebase_options.dart';
import 'package:my_app/my_app.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); // Uses options configured by FlutterFire CLI
// Does not work regardless of whether this line is commented out
// FirebaseFunctions.instance.useFunctionsEmulator('localhost', 5001);
HttpsCallable ping = FirebaseFunctions.instance.httpsCallable('ping');
await ping(); // Exception thrown on this line
runApp(const MyApp());
}
When running this code, I get a FirebaseFunctionsException ([firebase_functions/17999] An internal error has occurred, print and inspect the error details for more information. error:
Even as I dive deeper into the call stack, I'm not able to get any helpful information. Setting a breakpoint in the call method of MethodChannelHttpsCallable shows me that the exception is thrown when calling the MethodChannelFirebaseFunctions.channel.invokeMethod method, but I can't see any immediately obvious reason why that would be failing.
I'm using other FlutterFire libraries in my app (specifically Auth and Firestore), with no problems at all, both with the emulator and the deployed Firebase project.