5

I am running an application for auto-login into Amazon and Walmart but sometimes the script is throwing protocol error. I mentioned the code for launching the browser below -

var browser = await puppeteer.launch({
    headless: false,
    ignoreHTTPSErrors: true,
    args: [
        '--disable-background-timer-throttling',
        '--disable-backgrounding-occluded-windows',
        '--disable-renderer-backgrounding',
        '--no-sandbox',
        '--disable-setuid-sandbox',
        '--ignore-ssl-errors'
    ],
    slowMo: Math.round(Math.random() * 10),
    userDataDir: dir
});
var page = await browser.newPage();
await page.setViewport({ width: 1280, height: 1024, deviceScaleFactor: 1 });

page.on('console', msg => {
    if (msg._type == "log")
        console.log(msg._text);
});
page.on('error', async (error) => {
    if (error.toString().match(/Page crashed/i)) {
        console.log("<--------- Page crashed ------------->");
        await browser.close();
    }
});
Krrish Yadav
  • 176
  • 1
  • 7
  • Does this answer your question? [Puppeteer - Protocol error (Page.navigate): Target closed](https://stackoverflow.com/questions/51629151/puppeteer-protocol-error-page-navigate-target-closed) – Thomas Dondorf Jun 01 '20 at 14:33
  • Thanks for your reply @ThomasDondorf I am not getting an error of Page.navigate. I am getting Performance.enable error. May it happen because of multiple browsers on the system? I am running 2 scripts on a machine that launches 1 browser for a user. I am launching around 4 browser instances on a machine. – Krrish Yadav Jun 02 '20 at 05:08

0 Answers0