【发布时间】:2020-09-07 08:34:39
【问题描述】:
我有一些看似很奇怪的行为。我一直在关注多个关于将 Firebase 集成到我的 Flutter 应用中的教程。
我正在尝试做一些非常简单的事情。当用户按下按钮时,会创建一个“会话”文档。
我有这个index.js:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.addSession = functions.https.onCall((data, context) => {
const sessions = admin.firestore().collection('sessions');
return sessions.add({
game: data['game'],
rules: data['rules'],
password: data['password'],
roomCode: data['roomCode'],
playerIds: data['playerIds']
});
});
在 Flutter 中调用时,数据成功写入数据库(我可以在控制台看到),但我也总是出现这个错误:
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: PlatformException(functionsError, Firebase function failed with exception., {message: INTERNAL, code: INTERNAL})
颤振调用:
final HttpsCallable callable =
CloudFunctions.instance.getHttpsCallable(functionName: 'addSession');
await callable.call(<String, dynamic>{
'game': game,
'rules': 'default',
'password': password,
'roomCode': _roomCode,
'playerIds': [123456],
});
对此非常困惑,maximum stack call size exceeded 结果似乎与此无关。这是非常简单的代码!
还想知道这是否与我遇到的阅读问题有关,我将在另一篇文章中询问。
【问题讨论】:
标签: javascript firebase flutter google-cloud-firestore google-cloud-functions