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

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

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

Loading…
Cancel
Save