gpt4 book ai didi

firebase - flutter 火 : Calling cloud function throws an internal error with no details - FirebaseFunctionsException [firebase_functions/17999]

转载 作者:行者123 更新时间:2023-12-05 05:47:20 27 4
gpt4 key购买 nike

我正在尝试在 FlutterFire docs 之后从我的 Flutter 应用程序调用一个非常简单的云函数,但我收到了一个非常不可读的错误。无论我是使用模拟器,还是尝试调用使用 Firebase 完全部署的函数,都会出现错误。

我的云函数代码:

import * as functions from "firebase-functions";

export const ping = functions.https.onCall(() => ({ ping: "pong" }));

还有我在 main.dart 中的 Flutter 代码:

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());
}

运行此代码时,我得到一个FirebaseFunctionsException([firebase_functions/17999] 发生内部错误,打印并检查错误详细信息以获取更多信息。 错误:Exception details

即使我深入调用堆栈,我也无法获得任何有用的信息。在MethodChannelHttpsCallablecall方法中设置断点向我展示了在调用 MethodChannelFirebaseFunctions.channel.invokeMethod 方法时抛出了异常,但我看不出任何立即明显的失败原因。

我在我的应用程序中使用其他 FlutterFire 库(特别是 Auth 和 Firestore),使用模拟器和部署的 Firebase 项目都没有任何问题。

最佳答案

我找到了解决这个问题的方法。在 Emulator UI 中,在 Authentication 选项卡中添加一个用户,并让您的 App 只用他登录一次。然后您可以注销并删除该用户。之后我的函数停止给出错误 17999 并且它正常工作。

关于firebase - flutter 火 : Calling cloud function throws an internal error with no details - FirebaseFunctionsException [firebase_functions/17999],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71028259/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com