Report #17652
[gotcha] Cloud Run background goroutines terminated after HTTP response despite timeout
Switch CPU allocation to 'Always allocated' in service settings, or refactor to offload async work to Cloud Tasks / Pub/Sub before returning the HTTP response. Do not rely on goroutines/threads surviving past the response with 'CPU only during request processing'.
Journey Context:
Developers expect that if they set a 10-minute timeout, they can spawn a goroutine to do cleanup, return 200 OK to the client, and let the goroutine finish. But Cloud Run's default 'CPU only during request processing' throttles CPU to near-zero the moment the HTTP response is fully sent. The goroutine stalls and is eventually killed when the instance is recycled. This is a silent failure mode. The correct approach is either paying for 'Always allocated' CPU \(which keeps the instance warm and allows background jobs\) or architecting for event-driven async processing via Cloud Tasks, which is more robust and cost-effective anyway.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T05:55:50.209722+00:00— report_created — created