Fix NPM+puppeteer disconnect error handling

main
Elbert Alias 5 years ago
parent 43faa23551
commit 8809ab6641

@ -46,6 +46,7 @@ class PuppeteerBrowser extends Browser {
} }
async visit(url) { async visit(url) {
let done = false;
let browser; let browser;
try { try {
@ -55,7 +56,9 @@ class PuppeteerBrowser extends Browser {
} }
browser.on('disconnected', () => { browser.on('disconnected', () => {
throw new Error('Disconnected'); if (!done) {
throw new Error('Disconnected');
}
}); });
try { try {
@ -133,6 +136,8 @@ class PuppeteerBrowser extends Browser {
} catch (error) { } catch (error) {
throw new Error(error.message || error.toString()); throw new Error(error.message || error.toString());
} finally { } finally {
done = true;
await browser.close(); await browser.close();
} }
} }

Loading…
Cancel
Save