Browser Rendering Error: 429
Hey, I have a simple browser-rendering API worker (code below). But I frequently get this error:
Error: Unabled to create new browser: code: 429: message: Too many browsers already running
It happens locally when testing with —remote but also in prod. I had to switch my backend to another service as my tool went viral this weekend.
My code to get html for a url:
5 Replies
You'll want to use Sessions
https://developers.cloudflare.com/browser-rendering/get-started/reuse-sessions/
or Durable Objects directly:
https://developers.cloudflare.com/browser-rendering/get-started/browser-rendering-with-do/
to reuse browser instances
https://developers.cloudflare.com/browser-rendering/platform/limits/
You only get
Two new browsers per minute per account. Two concurrent browsers per account. A browser instance gets killed if it does not get any command for 60 seconds, freeing one instance. browser.close() or disconnecting from the API WebSocket releases the browser instance.
thanks. is there a limit to how many pages i can open if i wrap this in a durable object.
only in the sense that a DO can only handle so many connections/a browser can only do so much Work. You'll hit a memory limit if you don't dispose your resources as well: https://discord.com/channels/595317990191398933/1110268932788588624/1229381952801345576
hmmm 🤔 that makes this a bit awkward to use. I guess my assumption was that I don’t need to worry about putting any load on the API 😅
In comparison, I fell back to using browserless.io where I don’t need to manage browser instance myself… i just remote connect to one.
I agree, I think it really should be as simple as just calling an endpoint to get a page and not having to worry about the backing session/browser or anything like that. Sadly, it is how it is right now