Browser Run - Multiple concurrent clients per session
Browser Run sessions now accept multiple concurrent connections instead of one at a time, allowing multiple Workers to connect to the same browser simultaneously. Each connection uses separate browser contexts to isolate pages, cookies, and storage, reducing cold-start time and browser limits.
Browser Run sessions now accept multiple concurrent connections. Before, a session accepted only one connection at a time, and other Workers had to wait until that connection closed. Now multiple Workers can connect to the same browser at the same time.
Each puppeteer.connect() call opens its own Chrome DevTools Protocol (CDP) connection. Create a separate browser context for each request to keep its pages, cookies, and storage apart from other clients.
const browser = await puppeteer.connect(env.MYBROWSER, sessionId);
const context = await browser.createBrowserContext();
try {
const page = await context.newPage();
await page.goto("https://example.com");
// ...
} finally {
await context.close();
await browser.disconnect(); // keep the shared browser running
}const browser = await puppeteer.connect(env.MYBROWSER, sessionId);
const context = await browser.createBrowserContext();
try {
const page = await context.newPage();
await page.goto("https://example.com");
// ...
} finally {
await context.close();
await browser.disconnect(); // keep the shared browser running
}
Sharing sessions means fewer new browsers to launch, less cold-start time, and fewer concurrent browsers counted against your limits.
Concurrent connections require @cloudflare/puppeteer version 1.1.0 or later.
Refer to Reuse sessions for a full example.
Source: original entry ↗
More from Cloudflare
Follow Cloudflare to get its new changes in your feed and email digest.
Cloudflare One Client for Windows hotfix - trusted certificate chains
A new GA release for Windows Cloudflare One Client is available, addressing an issue with building trusted certificate chains.
Cloudflare One Client for macOS - Trusted Certificate Chain Fix
A new GA release of the macOS Cloudflare One Client is available. This hotfix addresses an issue with building trusted certificate chains.
Cloudflare One Client for Linux
A new GA release of Cloudflare One Client for Linux is now available. This hotfix addresses an issue with building trusted certificate chains.