Skip to content

Commit

Permalink
restart puppeteer each 16 pages
Browse files Browse the repository at this point in the history
the latest `puppeteer` versions can crash after less number of loaded pages, regression of puppeteer/puppeteer#7050
  • Loading branch information
zloirock committed Dec 27, 2021
1 parent 39c825a commit b40784e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/usage.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ await Promise.all(Array(Math.ceil(os.cpus().length / 2)).fill(0).map(async i =>
site = sites.pop();
name = site.replace(/^https?:\/\//, '');
// restart browser each some pages for prevent possible `puppeteer` crash and memory leaks
if (!(i++ % 64) || !browser) {
if (!(i++ % 16) || !browser) {
if (browser) await browser.close();
browser = await puppeteer.launch();
}
Expand Down

0 comments on commit b40784e

Please sign in to comment.