Fix error handling in NPM/Puppeteer

main
Elbert Alias 5 years ago
parent dc7ffd175e
commit 0ae0d8889f

@ -68,18 +68,19 @@ class PuppeteerBrowser extends Browser {
}
async visit(url) {
return new Promise(async (resolve, reject) => {
let done = false;
let browser;
try {
browser = await this.browser();
} catch (error) {
throw new Error(error.message || error.toString());
reject(new Error(error.message || error.toString()));
}
browser.on('disconnected', () => {
if (!done) {
throw new Error('Disconnected');
reject(new Error('Disconnected'));
}
});
@ -90,9 +91,7 @@ class PuppeteerBrowser extends Browser {
await page.setRequestInterception(true);
page.on('error', (error) => {
throw new Error(error.message || error.toString());
});
page.on('error', reject);
page.on('request', request => request.continue());
@ -122,7 +121,7 @@ class PuppeteerBrowser extends Browser {
await Promise.race([
page.goto(url, { waitUntil: 'networkidle2' }),
new Promise(resolve => setTimeout(resolve, this.options.maxWait)),
new Promise(_resolve => setTimeout(_resolve, this.options.maxWait)),
]);
// eslint-disable-next-line no-undef
@ -156,12 +155,13 @@ class PuppeteerBrowser extends Browser {
this.html = await page.content();
} catch (error) {
throw new Error(error.message || error.toString());
reject(error.message || error.toString());
} finally {
done = true;
await browser.close();
}
});
}
}

@ -2,7 +2,7 @@
"name": "wappalyzer",
"description": "Uncovers the technologies used on websites",
"homepage": "https://github.com/AliasIO/Wappalyzer",
"version": "5.9.12",
"version": "5.9.13",
"author": "Elbert Alias",
"license": "GPL-3.0",
"repository": {

@ -322,7 +322,7 @@ class Wappalyzer {
*
*/
ping() {
if (Object.keys(this.hostnameCache).length > 100) {
if (Object.keys(this.hostnameCache).length > 25) {
this.driver.ping(this.hostnameCache);
this.hostnameCache = {};

Loading…
Cancel
Save