From 92101aa0ba342e6767f9637e95a05b68318df67e Mon Sep 17 00:00:00 2001 From: Arne Setzer Date: Wed, 7 Aug 2024 13:52:11 +0200 Subject: [PATCH] feat: throw on invalid hostname (#212) * fix inifinte loop with invalid hostname * fix spacing * add hostname to error message invalid hostname --------- Co-authored-by: arnesetzer <25772747+arnesetzer@users.noreply.github.com> --- lib/request_urls.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/request_urls.js b/lib/request_urls.js index c22e102..b061cd5 100644 --- a/lib/request_urls.js +++ b/lib/request_urls.js @@ -79,6 +79,10 @@ function request_urls(config, urls, callback) { request( requestOpts, function ( err, res ){ if( err ){ console.error( err ); + //Check if hostname is valid. Abort execution if not + if( err.code === 'ENOTFOUND' ) { + throw new Error( 'Invalid hostname: "'+ err.hostname + '". Stopping execution.' ); + } urls.push(url); } else if( shouldRetryRequest(res) ){