puppeteer-extra
puppeteer-extra copied to clipboard
[Bug] TargetCloseError: Protocol error puppeteer-extra-plugin-stealth
0|bots | TargetCloseError: Protocol error (Page.addScriptToEvaluateOnNewDocument): Session closed. Most likely the page has been closed. 0|bots | at CdpCDPSession.send (/root/B1/api/node_modules/puppeteer-core/src/cdp/CDPSession.ts:90:9) 0|bots | at next (/root/B1/api/node_modules/puppeteer-extra-plugin-stealth/evasions/sourceurl/index.js:34:41) 0|bots | at CdpCDPSession.send (/root/B1/api/node_modules/puppeteer-extra-plugin-stealth/evasions/sourceurl/index.js:67:18) 0|bots | at CdpPage.evaluateOnNewDocument (/root/B1/api/node_modules/puppeteer-core/src/cdp/Page.ts:1025:58) 0|bots | at Object.evaluateOnNewDocument (/root/B1/api/node_modules/puppeteer-extra-plugin-stealth/evasions/_utils/withUtils.js:33:17) 0|bots | at Plugin.onPageCreated (/root/B1/api/node_modules/puppeteer-extra-plugin-stealth/evasions/webgl.vendor/index.js:27:27) 0|bots | at Plugin._onTargetCreated (/root/B1/api/node_modules/puppeteer-extra-plugin/src/index.ts:544:22) 0|bots | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
I also have this issue. Any workaround you found @Biswajit96 ?
no its there but before close page try to remove all task await page.removeAllListeners(); how you will still get errors but it will reduce the number of the error.
page.on('error', err => { pageLogger.info('crash', err); page.removeAllListeners(); });