Skip to content
Rush Commerce
Software & Dev3 min read

Cloudflare Browser Run /script: Playwright in one API call

Cloudflare Browser Run now runs Playwright, Puppeteer or CDP scripts in one API call with no Worker to deploy. Sessions stay open after the run, so close them.

Cloudflare Browser Run now accepts a Playwright, Puppeteer or raw CDP script in a single API request. You send a JavaScript function, Cloudflare runs it against a hosted browser and returns the result. You do not deploy a Worker. For small teams that need a browser in the loop, like supplier portals with no API, price checks or screenshot QA, a lot of setup just went away. One billing detail needs attention: the session stays open after your script ends.

What actually happened

Cloudflare's November 20 changelog and the /script docs describe it:

  • Endpoint: POST /accounts/{account_id}/browser-run/script with a JSON body. code is required and holds an async function. library is "playwright" or "puppeteer"; leave it out for raw CDP.
  • Isolation: your function runs in an isolated Worker connected to a browser session.
  • Follow-ups: the response returns a session ID header, and POST .../script/{sessionId} runs another script in the same browser.
  • Timeouts: a script run defaults to 60 seconds, with a 120-second maximum. Idle sessions stay alive 60 seconds by default, and you can set keep_alive as high as 20 minutes.
  • Workers binding: env.BROWSER.script(code, { library }) does the same from inside a Worker, with no API token.

Why it matters for your business

Most of the business automations we build still hit a website somewhere. That can be a distributor's order portal, a carrier's tracking page or a competitor's price list. Before, that meant running your own headless Chrome or deploying a Worker just to hold the browser. Now it is one HTTP call from any backend or agent.

The catch is in the pricing page. Billing runs for the session's lifetime, and /script does not close the session when your script returns. On Workers Paid you get 10 browser hours a month, then $0.09 per hour, and 10 concurrent browsers, then $2 per extra browser. One stuck loop that opens sessions with a 20-minute keep_alive can use up that allowance fast.

Our build rules for this:

  • Close every session. Call browser.close() in a finally block, or DELETE the session when you are done.
  • Keep keep_alive short unless you reuse the session on purpose.
  • Log X-Browser-Ms-Used from each response, so you see browser time per job, not just a monthly bill.
  • Respect the site. Check the terms of any portal you automate, and use the official API when one exists.

Key takeaways

  • Browser Run /script runs Playwright, Puppeteer or CDP code in one API call, with no Worker deploy
  • Script runs cap at 120 seconds; sessions can stay alive up to 20 minutes
  • Sessions do not close after the script; you pay until they close or time out
  • Workers Paid includes 10 browser hours a month, then $0.09 per hour
  • Close sessions in code and log browser time per job

Got a vendor portal your team still clicks through by hand? We build browser automations with session cleanup, retries and cost logging, so one Playwright script does not turn into a surprise bill. See what we have built or send us the portal.

Sources: Cloudflare changelog, Cloudflare Browser Run /script docs, Cloudflare Browser Run pricing.

  • #cloudflare
  • #browser-automation
  • #playwright
  • #puppeteer
  • #headless-browser
TR

Tommy Rush — Founder, Rush Commerce

Operator turned builder. 15+ years running operations — now shipping the systems businesses run on. More

Get The Rush Report weekly — one email, zero fluff.