From 2c84f933095ecc6e8d36061102e5b97d7672cb7a Mon Sep 17 00:00:00 2001 From: Giga <52905881+giga-a@users.noreply.github.com> Date: Thu, 12 May 2022 13:06:34 -0700 Subject: [PATCH] Update helper.js --- modules/helper.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/helper.js b/modules/helper.js index ca649de..3558cdf 100755 --- a/modules/helper.js +++ b/modules/helper.js @@ -186,7 +186,7 @@ function get_site_from_url (_url) { return temp.replace('nothinghere.', '') } -async function get_url_wrapper_json (url, time = 5) { +async function get_url_wrapper_json (url, time = 2) { try { const http_promise = new Promise((resolve, reject) => { const request = https.get(url, header_options, function (res) { @@ -219,7 +219,7 @@ async function get_url_wrapper_json (url, time = 5) { } } -async function get_url_wrapper_text (url, time = 5) { +async function get_url_wrapper_text (url, time = 2) { const response_body = 'error-get-url' try { const http_promise = new Promise((resolve, reject) => { @@ -232,6 +232,12 @@ async function get_url_wrapper_text (url, time = 5) { resolve(body) }) }) + const timeout = (time !== 0) ? time * 1000 : 5000 + request.setTimeout(timeout, function() { + reject({ + data: '' + }) + }); request.on('error', function (e) { reject({ data: ''