(Created on )

Puppeteer: CDPSession is not instance of CdpCDPSession

A CDP-only internal path received a different CDPSession implementation.


A CDP-only internal path received a different CDPSession implementation.

Error message

CDPSession is not instance of CdpCDPSession

How this error happens

A CDP-only internal operation requires a CdpCDPSession, not a BiDi bridge session. Mixing sessions from different connection modes can violate that assumption.

The snippets use the imported puppeteer instance. Keep sessions within the connection that created them.

const browser = await puppeteer.launch({
    browser: "chrome",
    protocol: "webDriverBiDi",
});

const page = await browser.newPage();
const session = await page.createCDPSession();

How to fix

Create the session from a Chrome/CDP connection when using CDP-only integrations.

const browser = await puppeteer.launch({
    browser: "chrome",
    protocol: "cdp",
});

const page = await browser.newPage();
const session = await page.createCDPSession();

try {
    await session.send(
        "Runtime.enable"
    );
} finally {
    await session.detach();
    await browser.close();
}

Things to keep in mind

A public createCDPSession call can succeed as a bridge without this error. This is the session-origin example; the internal mismatch occurs only when a CDP-only consumer later receives the bridge. Do not cast or mutate a BiDi session into a CDP session.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →