mediumIntermediateRED#cloud functions#timeout#timeout exceeded#gen1#gen2

Cloud Functions timeout exceeded (300s max)

Function logs show Function execution took too long, finished with status: 500

Likely source:performanceavailability

Focused incident mode — strips away everything but this runbook.

Symptoms

  • Function logs show Function execution took too long, finished with status: 500
  • HTTP calls to the function time out past its set limit
  • The timeout limit is reached with ongoing background work
  • Cloud Functions dashboard shows Execution Error with 'timeout' in the message

Cloud Functions are request-scoped: raising the timeout only helps if returning early on an async pattern is not possible. If work routinely needs minutes, hand it to Cloud Tasks/Workflows.

Evidence to grab

Collect these artifacts before you change anything — they prove (or rule out) each cause.

  • Configured timeout vs duration

    gcloud functions describe <FUNCTION> --region <REGION> --format='value(serviceConfig.timeoutSeconds)'
  • Execution logs around the timeout

    gcloud functions logs read <FUNCTION> --region <REGION> --limit=20

Diagnostic flow

Run the steps in order, marking each claim confirmed or refuted. The evidence you gather feeds the ranked causes below.

Guided decision tree is ready.

Steps with commands, expected output, and pass/fail branches.

Ranked root causes

Evidence checklist

  • Logs show executions increasing in duration until they hit the cap
  • Heavy work (migrations, big queries) runs inside the function
  • Raising the limit fixes it

Confirm before fixing

gcloud functions describe <FUNCTION> --region <REGION> --format='value(serviceConfig.timeoutSeconds)'
READ

Read the timeout setting

Expected: A value below the observed execution duration

Fix

gcloud functions update <FUNCTION> --region <REGION> --timeout=<540>
CHANGE

Raise the timeout (max 540s Gen1)

Expected: Updated [<FUNCTION>].

Resolution runbook

Apply from top to bottom after the cause is confirmed. Review every command before running it — risk tags are shown on each.

1
gcloud functions describe <FUNCTION> --region <REGION> --format='value(serviceConfig.timeoutSeconds)'
READ

Read the current limit

2
gcloud functions logs read <FUNCTION> --region <REGION> --limit=50
READ

See the execution duration trend

3
gcloud functions update <FUNCTION> --region <REGION> --timeout=<540>
CHANGE

Raise the timeout to the valid maximum if needed

4
gcloud functions describe <FUNCTION> --region <REGION> --format='value(status)'
READ

Verify the function is ACTIVE after update

Prevention

  • Set the function timeout explicitly instead of relying on defaults.
  • Alert on execution duration ratio nearing the timeout (e.g., P95 > 80%).
  • Refactor long sync work into async jobs with client polling or push notifications.
  • Profile upstream latency before tuning the function itself.

Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.