Skip to content

multi contexts and multi pages is not supported #882

@pakerekchdz

Description

@pakerekchdz

A single page loads fine, but when I try to load multiple contexts/pages, I get an error. I'm using the latest version, released 8 hours ago, and the standard implementation (as per the docs). Could I get some quick help?

my error:

PS D:\Desktop\browser_test_lightpanda> npx tsx skrypt4.ts
D:\Desktop\browser_test_lightpanda\node_modules\.pnpm\puppeteer-core@24.12.1\node_modules\puppeteer-core\src\cdp\Browser.ts:205
    const {browserContextId} = await this.#connection.send(
           ^


TypeError: Cannot destructure property 'browserContextId' of '(intermediate value)' as it is undefined.
    at CdpBrowser.createBrowserContext (D:\Desktop\browser_test_lightpanda\node_modules\.pnpm\puppeteer-core@24.12.1\node_modules\puppeteer-core\src\cdp\Browser.ts:205:12)
    at async Promise.all (index 1)
    at <anonymous> (D:\Desktop\browser_test_lightpanda\skrypt4.ts:13:18)

Node.js v20.12.0

server error:

$time=1752234963974 $scope=app $level=error $msg="server read error" err=ConnectionResetByPeer

my code:

import puppeteer from 'puppeteer-core';

const browser = await puppeteer.connect({
  browserWSEndpoint: "ws://:9222",
});

const travelSites = [
  "https://www.booking.com",
  "https://www.tripadvisor.com",
  "https://www.expedia.com"
]

const contexts = await Promise.all([
  browser.createBrowserContext(),
  browser.createBrowserContext(),
  browser.createBrowserContext()
]);

// Process multiple pages simultaneously
const results = await Promise.all(
  contexts.map(async (context, index) => {
    const page = await context.newPage();
    await page.goto(travelSites[index]);
    return await page.title();
  })
);

console.log(results);

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions