4
votes

I can't get a Google Cloud Function to run for more than 60secs, even when the timeout is set to 540secs!! Any suggestions?

I set the timeout flag on deployment to --timeout=540, and I know the setting goes through, because the 540 sec timeout setting appears in the GCP WEB UI. I have also tried to manually edit the timeout to 540 through the GCP WEB UI. But in any case i still get the DEADLINE_EXCEEDED after just ~ 62000 ms.

I have tried both the pub/sub and https methods as the func trigger, but still get the premature function timeout at ~60s.

Im running the latest CLI, with these these func settings:

  • trigger: http/pubsub (both tested, same result)
  • availableMemoryMb: 2048
  • runtime: nodejs6
  • status: ACTIVE
  • timeout: 540s

Thanks for any inputs!

Br Markus

3
anyone at the google cloud platform team?mkelle
In my case local node js emulator timeouts while after deploying it to gcloud it worksAli Zaidi

3 Answers

3
votes

I have used the documentation code for delay and executed a Cloud Function with the same specifications as yours. In the documentation, the execution is delayed 120000 ms (2 mins). I edited that and put it at 500000 ms. This plus the normal time that the CF takes to execute, will reach the desired execution time (around 9 minutes). If you add 540000 to test the code, it will execute with timeout error at ~540025, because the value itself is exceeding the timeout limit of the Cloud Function and at the same time the default maximum timeout limit of a Cloud Function, which is 9 minutes.

I also tried the creating the function using this command gcloud functions deploy [FUNCTION_NAME] --trigger-http --timeout=540. After successful deployment, I updated the code manually in the GCP Cloud Function UI as follows

exports.timeoutTest = (req, res) => {
  setTimeout(() => {
    let message = req.query.message || req.body.message || 'Hello World today!';
    res.status(200).send(message);
    res.end();
  }, 500000); 
};

Both times the Cloud Function was executed and returned with status code 200. This means that you can set a timeout to be more than 60 secs which is the default value.

If you revised everything correctly and you still have this issue, I recommend you to start afresh, create a new CF and use the documentation link I provided.

0
votes

The 60 seconds timeout is not resulting from GCP Cloud Function setting. For instance if this is a Django/Gunicorn App, the timeout is coming from the timeout of gunicorn that is set in app.yaml

entrypoint: gunicorn -t 3600 -b :$PORT project_name.wsgi

For instance, this will achieve a timeout of 3600 seconds for gunicorn.

0
votes

I believe I'm some years late but here is my sugestion.

If you're using the test this function button in the testing tab in the gcp console it says right after the button that:

Testing in the Cloud Console has a 60s timeout. Note that this is different from the limit set in the function configuration.

I hope you fixed it and this answer can help someone in the future.