I have the following code:
puppeteer.launch().then(async browser => { for (let id of ids) { try { const page = await browser.newPage(); //const url = 'chrome://crash'; await page.goto(url + id) await page.waitFor(5000); await page.screenshot({ path: path.join(__dirname, "../public/images/screenshots/" + id + ".png"), clip: { x: 10, y: 70, width: 780, height: 470} }); } catch (error) { console.log('Exception', id, error.message); page.close(); } }; browser.close(); }); It generally works OK but I'm having problems with a particular page (with a URL that unfortunately I can't share).
This page tries to load a GB of data and causes Chrome to crash, so I guess it's causing Chromium to crash too.
The error I see from this page is: Exception 6766 Navigation Timeout Exceeded: 30000ms exceeded. This is fine, but it doesn't seem to stop at this point - it causes my whole server to hang, I guess because it's trying to use too much memory at the OS level.
How can I stop my server from hanging and handle this gracefully? Are there flags I can provide to Chromium to limit the memory used and give up gracefully? I'm also not sure my error handling as a whole is correct, so any tips would be appreciated.