使用firebase仿真器时调用firebase云函数会导致decored_exceeded错误
我有一个非常简单的云功能,可以返回JSON中的字符串。
const functions = require("firebase-functions");
// Create and Deploy Your First Cloud Functions
// https://firebase.google.com/docs/functions/write-firebase-functions
exports.helloWorld = functions.https.onRequest((request, response) => {
functions.logger.info("Hello logs!", {structuredData: true});
response.send({data: "Hello from Firebase!"});
});
我称其为这样(App在Android模拟器中运行):
async function callFirebaseCloudFunction() {
try
{
functions().useEmulator('localhost', 5001);
const helloWorldFunction = functions().httpsCallable('abcd');
const response = await helloWorldFunction();
console.log(response?.data);
alert(response?.data);
}
catch (error)
{
console.log("====",error);
alert(`${JSON.stringify(error)}` );
}
}
问题是我正在获得deadline_exceeded
错误。
请注意,我还在运行firebase的云功能模拟器,因此此行: functions()。使用Emulator('localhost',5001);
否则,评论上行并调用已部署的函数正常工作。
I've got a very simple cloud function that returns a string in a JSON.
const functions = require("firebase-functions");
// Create and Deploy Your First Cloud Functions
// https://firebase.google.com/docs/functions/write-firebase-functions
exports.helloWorld = functions.https.onRequest((request, response) => {
functions.logger.info("Hello logs!", {structuredData: true});
response.send({data: "Hello from Firebase!"});
});
And I am calling it like this(app is running in android emulator):
async function callFirebaseCloudFunction() {
try
{
functions().useEmulator('localhost', 5001);
const helloWorldFunction = functions().httpsCallable('abcd');
const response = await helloWorldFunction();
console.log(response?.data);
alert(response?.data);
}
catch (error)
{
console.log("====",error);
alert(`${JSON.stringify(error)}` );
}
}
The issue is that I am getting DEADLINE_EXCEEDED
error.
Note that I am also running firebase's emulator for cloud function, therefore this line:functions().useEmulator('localhost', 5001);
Otherwise, commenting the above line and calling the deployed function works fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
花了一个多小时,并写了这个问题。我终于弄清楚了这个问题(一种),所以我认为我应该回答。
我正在使用Genymotion的Android模拟器,并且请求不断失败“ deadline_exceed”错误。当我使用AVD(来自Android Studio的Android虚拟设备)时,它的工作正常。
After spending more than an hour, and writing this question. I finally figured out the problem(kind of), so I thought I should just answer it.
I was using the android emulator of Genymotion, and the request kept failing "DEADLINE_EXCEEDED" error. When I used avd(android virtual device from Android Studio), it worked totally fine.