Puppeteer: Unknown CDP session with id {value}
The BiDi-over-CDP adapter cannot find the requested CDP session ID.
The BiDi-over-CDP adapter cannot find the requested CDP session ID.
Error message
Unknown CDP session with id {value}
{value} is replaced by the value shown in your error message.
How this error happens
A BiDi-over-CDP adapter received a command or event for a CDP session it did not recognize. This can accompany session teardown or inconsistent browser/protocol event ordering.
The snippets use an open CDP-capable page named page. The first sequence illustrates a session lifecycle problem, not a guaranteed reproduction of an internal map failure.
const session = await page.createCDPSession();
await page.close();
await session.send(
"Runtime.evaluate",
{
expression: "1 + 1",
}
);
How to fix
Keep the page alive while using its session and clean up in order. Run the correction on a new open page.
const session = await page.createCDPSession();
try {
const result = await session.send(
"Runtime.evaluate",
{
expression: "1 + 1",
}
);
console.log(result.result.value);
} finally {
await session.detach();
await page.close();
}
Things to keep in mind
The closure example can produce a session-closed error before reaching this particular registry check. If the exact error occurs without teardown, isolate custom transports, plugins and manual target-attachment commands. Do not supply guessed session IDs.