From 02601557d232b64467ea3fd13c5396b2197ce23b Mon Sep 17 00:00:00 2001 From: Elbert Alias <77259+AliasIO@users.noreply.github.com> Date: Tue, 19 Jan 2021 11:46:54 +1100 Subject: [PATCH] Fix status is undefined bug in NPM driver --- src/drivers/npm/driver.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/drivers/npm/driver.js b/src/drivers/npm/driver.js index f66ac0444..f04de865c 100644 --- a/src/drivers/npm/driver.js +++ b/src/drivers/npm/driver.js @@ -175,6 +175,7 @@ class Driver { } }) } catch (error) { + console.log('a', error) throw new Error(error.toString()) } } @@ -190,6 +191,7 @@ class Driver { this.log('Browser closed') } catch (error) { + console.log('b', error) throw new Error(error.toString()) } } @@ -225,6 +227,7 @@ class Site { try { this.originalUrl = new URL(url) } catch (error) { + console.log('c', error) throw new Error(error.toString()) } @@ -345,6 +348,7 @@ class Site { request.continue({ headers }) } } catch (error) { + console.log('d', error) this.error(error) } }) @@ -387,6 +391,7 @@ class Site { } } } catch (error) { + console.log('e', error) this.error(error) } }) @@ -690,7 +695,11 @@ class Site { } // Validate response - if (url.protocol !== 'file:' && !this.analyzedUrls[url.href].status) { + if ( + url.protocol !== 'file:' && + this.analyzedUrls[url.href] && + !!this.analyzedUrls[url.href].status + ) { await page.close() this.log('Page closed') @@ -751,6 +760,7 @@ class Site { return reducedLinks } catch (error) { + console.log('f', error) if (error.constructor.name === 'TimeoutError') { throw new Error('The website took too long to respond') } @@ -779,6 +789,7 @@ class Site { await this.batch(links.slice(0, this.options.maxUrls), depth + 1) } } catch (error) { + console.log('g', error) this.analyzedUrls[url.href] = { status: 0, error: error.message || error.toString(),