【问题标题】:Firebase Cloud Function Uncaught Exceptions - Do They Cause a Cold Start?Firebase 云功能未捕获的异常 - 它们会导致冷启动吗?
【发布时间】:2018-01-02 03:49:09
【问题描述】:

对于知情人士来说可能是一个简单的问题......

我正在阅读 Firebase Cloud Functions 和 GCP Cloud Functions 的文档,并注意到处理错误的推荐方法有所不同。这让我很惊讶,因为我的理解是 Firebase Cloud Functions 与 GCP Cloud Functions 密切相关。

Firebase documentation on error reporting中表示可能会抛出错误来获取到StackDriver,如下:

throw new Error('Fail!');

同时,GCP Cloud Function documentation on error reporting 声明未捕获的异常会强制对未来的调用进行冷启动。相反,建议如下:

console.error(new Error('Fail!'));

直接抛出错误是否也会导致 Firebase Cloud Functions 冷启动?在 Firebase 上,将错误发送到控制台可以避免这个问题吗?

谢谢。

【问题讨论】:

    标签: firebase google-cloud-functions


    【解决方案1】:

    Cloud 的文档是正确的。目前,需要更新 Firebase 文档以匹配针对 Cloud 所做的更改。

    函数抛出 3 个异常后,实例将重新启动。在每个then 链之后catch 可能符合您的最大利益,并使用console.error() 记录错误。

    【讨论】:

    • 感谢您的回答。很有帮助。
    猜你喜欢
    • 2020-12-23
    • 2021-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-16
    • 1970-01-01
    • 2012-11-10
    相关资源
    最近更新 更多