Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 319
Lindauson Avatar asked Apr 11 '17 18:04

Lindauson


People also ask

How to change Firebase function timeout?

1 Navigate to your project: console.cloud.google.com/functions/…>. 2. Click "Edit" to adjust Timeout.

Why Cloud function deployment failed?

Cloud Functions deployment can fail if the entry point to your code, that is, the exported function name, is not specified correctly. Your source code must contain an entry point function that has been correctly specified in your deployment, either via Cloud console or Cloud SDK.

How do I set memory allocation and timeout in Firebase?

To set memory allocation and timeout in functions source code, use the runWith parameter introduced in Firebase SDK for Cloud Functions 2.0.0. This runtime option accepts a JSON object conforming to the RuntimeOptions interface, which defines values for timeoutSeconds and memory .

What is the difference between Firebase CLI and cloud build?

The Firebase CLI creates a .zip archive of the function code, which is then uploaded to a Cloud Storage bucket (prefixed with gcf-sources) in your Firebase project. Cloud Build retrieves the function code and builds the function source.

What is Cloud Functions for Firebase?

Please try again later. Cloud Functions for Firebase is a serverless framework that lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your JavaScript or TypeScript code is stored in Google's cloud and runs in a managed environment.

Does the time zone of Cloud Functions for Firebase scheduler change?

Time Zone of Cloud Functions for Firebase Scheduler does not change I am currently creating and deploying a function to be executed periodically in the Cloud Functions for Firebase scheduler as shown below. The key point is that I want it to be executed every day at 0:05 Japan time as .timeZone (‘Asia/Tokyo’).


Video Answer


4 Answers

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

like image 200
Sanyam Jain Avatar answered Oct 18 '22 17:10

Sanyam Jain


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
4GB
8GB
like image 43
vir us Avatar answered Oct 18 '22 18:10

vir us


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.

like image 29
BGitlin Avatar answered Oct 18 '22 18:10

BGitlin


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.

like image 27
Lindauson Avatar answered Oct 18 '22 17:10

Lindauson