Set timeout for Cloud Functions for Firebase does not persist in the Console; is this a bug?

21,785

Solution 1

Default timeout can be changed here https://console.cloud.google.com/functions/list
select function >test function > edit > timeout

Solution 2

Starting functions v2.0.0 you can also set the timeout in your function declaration as described in the doc under the "Set timeout and memory allocation" section:

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

As release notes also highlighted:

You will need firebase-tools >=v4.0.0.

And on Mac you can get the latest firebase-tools with the following command:

npm install -g firebase-tools

Also note the limitations and valid values as per the doc link above:

The maximum value for timeoutSeconds is 540, or 9 minutes. 
Valid values for memory are:

128MB
256MB
512MB
1GB
2GB

Solution 3

After you select your function and then press "Edit" it is located under the "More" drop-down at the bottom of the page. The current max is 540 seconds.

Solution 4

Per @MichaelBleigh's comment. This has been resolved in the latest version of the Firebase CLI (3.7.0 at the time of this post).

If you are still experiencing this issue, make sure you are using the latest version of the Firebase CLI.

Share:
21,785
Lindauson
Author by

Lindauson

Updated on January 24, 2020

Comments

  • Lindauson
    Lindauson over 4 years

    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.

    I have a Cloud Function that needs to run past the default 60 second timeout in some edge-cases.

    The issue is, while this value can be changed in the Cloud Functions section of the Google Cloud Developer Console, it reverts to the original default after each deploy.

    Is there a way I can persist the changes to this setting, perhaps in one of the Firebase configuration files?

  • Mike
    Mike over 6 years
    How was it resolved? Is there a higher default? A way to specify a per function timeout value in the firebase.json? I checked the CLI reference and didn’t see anything.
  • Lindauson
    Lindauson over 6 years
    This gets set in the Cloud Functions section of the Google Cloud Developer Console. 1 Navigate to your project: console.cloud.google.com/functions/…>. 2. Click "Edit" to adjust Timeout.
  • vir us
    vir us over 5 years
    one can also now set the timeout and memory configuration per function declaration right in the code. Check my answer below for more details
  • krishnazden
    krishnazden over 5 years
    There is a max limit of 9 minutes( 540 seconds)
  • vir us
    vir us over 5 years
    thanks @krishnazden, added that part of the doc for shortcut