Puppeteer: Protocol error ({value}): Session with given id not found.
CDP reports that a command's session ID no longer exists.
CDP reports that a command’s session ID no longer exists.
Error message
Protocol error ({value}): Session with given id not found.
{value} is replaced by the value shown in your error message.
How this error happens
The browser no longer recognized the session ID used for a CDP command. 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.