Puppeteer: Connection closed. Most likely the page has been closed.
A command is sent after the underlying connection closed.
A command is sent after the underlying connection closed.
Error message
Connection closed. Most likely the page has been closed.
How this error happens
Once the browser connection is gone, Puppeteer cannot send a page-close command through it. Reusing a page after disconnecting illustrates that lifecycle mistake.
The snippets use a live page and its browser connection.
browser.disconnect();
await page.close();
How to fix
Close owned pages before disconnecting. If you launched the browser and want it to stop, use browser.close instead.
await page.close();
browser.disconnect();
Things to keep in mind
Run the correction with a live connection. The exact message depends on when closure is observed; a session-closed error may appear instead. disconnect leaves a remotely managed browser running.