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();
    }
});
