首页 文章

Cloud Functions for Firebase的设置超时不会在控制台中保留;这是一个错误吗?

提问于
浏览
16

Update: I updated the question, to reflect what I described in the body of the question, and what was happening at the time. It also justifies why I did not mark Sanyam's response as correct. There was a bug in the Console that was causing the timeout values to be ephemeral. @MichaelBleigh's response was the most pertinent, letting me know when the issue was resolved.

我有一个Cloud Function,在某些边缘情况下需要超过默认的60秒超时 .

问题是,虽然可以在Google Cloud Developer Console的“ Cloud 功能”部分更改此值,但在每次部署后它都会恢复为原始默认值 .

有没有办法可以将更改保留在此设置中,可能是在其中一个Firebase配置文件中?

4 回答

  • 3

    选择功能然后按“编辑”后,它位于页面底部的“更多”下拉菜单下方 . 当前最大值为540秒 .

  • 7

    functions v2.0.0开始,您还可以按照"Set timeout and memory allocation"部分下的文档中的说明在函数声明中设置超时:

    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
      });
    

    发行说明也强调:

    您将需要firebase-tools> = v4.0.0 .

    在Mac上,您可以使用以下命令获取最新的 firebase-tools

    npm install -g firebase-tools
    
  • 29

    默认超时可以在这里更改https://console.cloud.google.com/functions/list
    select function > test function > edit > timeout

  • 1

    Per @ MichaelBleigh的评论 . 这已在最新版本的Firebase CLI中解决(本文发布时为3.7.0) .

    如果您仍遇到此问题,请确保使用的是最新版本的Firebase CLI .

相关问题