【问题标题】:Cloud functions for firebase finished with status: 'timeout'Firebase 的云功能以状态完成:“超时”
【发布时间】:2017-08-26 06:12:14
【问题描述】:

函数执行时没有错误。我正在获取状态

函数执行耗时 60004 毫秒,完成状态为:'timeout'

我不确定问题是什么。我的功能中的所有内容对我来说都很好。我还注意到功能有时需要几秒钟来更新数据库,有时它是即时的。执行时间从瞬间变化到几秒钟是否正常?执行时间应该是即时的吗?

exports.countproposals = functions.database.ref("/proposals/{jobid}/{propid}").onWrite((event) => {
    const jobid = event.params.jobid;
    const userId = event.params.propid;
    const userRef = admin.database().ref(`users/${userId}/proposals/sent`);
    if (event.data.exists() && !event.data.previous.exists()) {
        userRef.child(jobid).set({
            timestamp: admin.database.ServerValue.TIMESTAMP
        });
    } else if (!event.data.exists() && event.data.previous.exists()) {
        userRef.child(jobid).remove();
    }
    const collectionRef = admin.database().ref(`/jobs/${jobid}`);
    const countRef = collectionRef.child("proposals");
    return countRef.transaction(current => {
        if (event.data.exists() && !event.data.previous.exists()) {
            return (current || 0) + 1;
        } else if (!event.data.exists() && event.data.previous.exists()) {
            return (current || 0) - 1;
        }
    });
});

【问题讨论】:

  • 请注意,Cloud Functions for Firebase 目前处于测试阶段。该团队仍在消除一些粗糙的边缘。当产品退出测试版时,应该有更好的性能保证。
  • 这里也一样,除此之外,该函数似乎又开始了。就像在无限循环中一样,我的日志正在堆积(我的情况是有错误)
  • 你是用实时模拟器还是本地模拟器运行的?

标签: firebase firebase-realtime-database google-cloud-functions


【解决方案1】:

根据我的经验,我猜这(希望)是 firebase 功能本身的临时问题。 对于昨天平均执行约 200 毫秒的函数,我收到了相同的警告/错误。

【讨论】:

    猜你喜欢
    • 2019-12-04
    • 2019-05-15
    • 2017-09-24
    • 2021-10-22
    • 1970-01-01
    • 2018-05-17
    • 2019-08-15
    • 1970-01-01
    • 2020-12-01
    相关资源
    最近更新 更多