whatsapp-api icon indicating copy to clipboard operation
whatsapp-api copied to clipboard

Notes on deploying to Google Cloud Run

Open wlhong-allo opened this issue 11 months ago • 3 comments

Figured that i might share how i got it worked to save some fellows hours.

I spent 2 days getting below errors running on Cloud Run:

"Initialize error: Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r1045629 is guaranteed to work." OR "Timed out waiting for nested object"

It turned out its because of the CPU allocation mechanism on Cloud Run.

check this out: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-on-google-cloud-run

You need to enable Google Cloud Run to always allocate dedicated CPU for you otherwise the process will exit as soon as a response is returned without waiting for the puppeteer event to come back.

As of current GCP web UI, goto your cloud run service > Edit & Deploy New Revision > under "Billing" section, select "Instance-based" instead of "Request-based"

Note that it impact your GCP cost because now there are CPU resources always dedicated for your service:

https://cloud.google.com/run/docs/configuring/billing-settings

Hope it helps~

wlhong-allo avatar Feb 15 '25 07:02 wlhong-allo

So, based on puppeteer docs, is that mean that whatsapp-api is not supported to run with google cloud run?

Image

afikri99 avatar May 28 '25 06:05 afikri99

In my case, it run quite stable for pass 3 months on Cloud Run, only downside is the higher cost of Instance-based allocation

wlhong-allo avatar May 28 '25 06:05 wlhong-allo

it's a shame if it can't be run with request-based billing :( Previously I've built this using compute engine, but because the cost is quite high, so I plan to move this to google cloud run (of course because the cost of this cloud run is based on request)

Do you know of an alternative so that it can be run and use request-based billing?

afikri99 avatar May 28 '25 06:05 afikri99