Fix NPM/Puppeteer error handling

main
Elbert Alias 5 years ago
parent f522a2b549
commit 3c6dcf6afb

@ -57,11 +57,12 @@ class PuppeteerBrowser extends Browser {
super(options);
}
visit(url) {
return new Promise(async (resolve, reject) => {
async visit(url) {
let done = false;
let browser;
try {
await new Promise(async (resolve, _reject) => {
try {
browser = await puppeteer.launch(chromium ? {
args: [...chromium.args, '--ignore-certificate-errors'],
@ -75,7 +76,7 @@ class PuppeteerBrowser extends Browser {
browser.on('disconnected', () => {
if (!done) {
reject(new Error('browser: disconnected'));
_reject(new Error('browser: disconnected'));
}
});
@ -83,7 +84,7 @@ class PuppeteerBrowser extends Browser {
page.setDefaultTimeout(this.options.maxWait * 2);
page.on('error', error => reject(new Error(`page error: ${error.message || error}`)));
page.on('error', error => _reject(new Error(`page error: ${error.message || error}`)));
page.on('response', (response) => {
try {
@ -105,7 +106,7 @@ class PuppeteerBrowser extends Browser {
this.contentType = headers['content-type'] || null;
}
} catch (error) {
reject(new Error(`page error: ${error.message || error}`));
_reject(new Error(`page error: ${error.message || error}`));
}
});
@ -155,19 +156,22 @@ class PuppeteerBrowser extends Browser {
resolve();
} catch (error) {
reject(new Error(`visit error: ${error.message || error}`));
} finally {
_reject(new Error(`visit error: ${error.message || error}`));
}
});
} catch (error) {
done = true;
if (browser) {
try {
await browser.close();
} catch (error) {
this.log(error.message || error.toString(), 'error');
} catch (_error) {
this.log(_error.message || _error.toString(), 'error');
}
}
throw new Error(error.message || error.toString());
}
});
}
}

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

@ -4,7 +4,7 @@
"author": "Elbert Alias",
"homepage_url": "https://www.wappalyzer.com",
"description": "Identify web technologies",
"version": "5.9.20",
"version": "5.9.22",
"default_locale": "en",
"manifest_version": 2,
"icons": {

Loading…
Cancel
Save