【问题标题】:How to configure timeout of Firebase functions on local如何在本地配置 Firebase 功能的超时
【发布时间】:2018-02-10 19:43:35
【问题描述】:

我想在 firebase 功能上做一些紧张的工作,通常需要 60 多秒。 在生产中,我可以从 Web 控制台设置更长的超时时间,但我找不到本地环境的设置。

以下是我用来开始服务的命令。

firebase serve --only functions

我正在使用 HTTPS 触发器,以下是在本地触发我的功能的命令。

functions-emulator call myfunc --data='{"uid":"user_id_1"}'

有没有办法在本地配置超时?

【问题讨论】:

    标签: firebase firebase-tools


    【解决方案1】:

    您可以将时间设置为 60 秒以上。

    可以在此处更改默认超时: Console Cloud functions


    选择函数->命名函数->编辑->超时

    【讨论】:

    • 这对本地环境下运行的函数也有效吗?
    • 我们的意思是在云功能上运行
    【解决方案2】:

    您可以使用 RunWith 函数在本地设置超时和内存选项

    const runtimeOpts = {
     timeoutSeconds: 300,
     memory: '1GB'
    }
    
    exports.myStorageFunction = functions
    .runWith(runtimeOpts)
    .storage
    .object()
    .onFinalize((object) = > {
      // do some complicated things that take a lot of memory and time
    });
    

    timeoutSeconds 的最大值为 540,即 9 分钟。内存的有效值为:

    128MB
    256MB
    512MB
    1GB
    2GB

    【讨论】:

    • 我想为 Firebase 实时数据库 Web SDK 设置一个低超时,你知道怎么做吗?
    猜你喜欢
    • 2018-05-17
    • 2019-07-08
    • 2018-11-25
    • 1970-01-01
    • 2019-11-23
    • 2018-11-21
    • 2017-07-31
    • 2021-08-22
    相关资源
    最近更新 更多