Function timeout (1st gen)
If a function runs for too long, the system takes steps to terminate or throttle it. This timeout period defaults to 60 seconds, but you can extend or reduce it when you deploy the function. The maximum timeout duration is nine minutes (540 seconds).
When function execution reaches its timeout, a response message with an HTTP error status, generally 408, is immediately returned to the caller; function execution is halted.
Set a timeout duration
You can set a function's timeout duration at deployment using the Google Cloud CLI or the Google Cloud console.
gcloud
If you are deploying using the gcloud CLI, use the
--timeout
flag:
gcloud functions deploy YOUR_FUNCTION_NAME --no-gen2 --timeout=TIMEOUT_DURATION ...
To edit an existing timeout duration with Google Cloud CLI, redeploy the function with a new timeout value.
Console
To set the timeout duration during function creation in the Google Cloud console:
- Go to the Cloud Run functions Overview page in the Google Cloud console.
- Click Create function.
- Fill in the required fields for your function.
- Expand the Runtime, build... section at the end of the page and click the Runtime tab.
In the Timeout field, enter a number of seconds.
To edit an existing timeout duration in Google Cloud console, on the functions overview page click the name of the function to go to its details page. On the details page click Edit, expand the Runtime, build... section, and click the Runtime tab, where you can directly edit the value in the Timeout field.