From 0645735d2bb5f3a3b005d8083fdf682926584fbf Mon Sep 17 00:00:00 2001 From: Max Baumann Date: Fri, 8 Nov 2019 19:57:20 +0100 Subject: [PATCH] Error responses from scraped pages should not return metadata (#2691) * Don't return error pages as valid scrapes * Fix linting * whitespace --- services/scraper/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/scraper/index.js b/services/scraper/index.js index 59faa8bf0..e8a51d337 100644 --- a/services/scraper/index.js +++ b/services/scraper/index.js @@ -75,6 +75,12 @@ const scraper = { }); const html = await res.text(); + if (!res.ok) { + let err = new Error(res.statusText); + err.response = res; + throw err; + } + // Get the metadata from the scraped html. const meta = await metascraper({ html,