diff --git a/package.json b/package.json index c101966..2735dc6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@squeebot/core", - "version": "3.1.0", + "version": "3.1.1", "description": "Squeebot v3 core for the execution environment", "main": "lib/index.js", "module": "lib/", diff --git a/src/common/http.ts b/src/common/http.ts index 893abdd..e07375f 100644 --- a/src/common/http.ts +++ b/src/common/http.ts @@ -10,9 +10,6 @@ export function httpGET( restrictToText = true, saveTo?: string, lback?: number): Promise { - if (lback && lback >= 4) { - throw new Error('infinite loop!'); - } const parsed = url.parse(link); const opts = { @@ -35,6 +32,10 @@ export function httpGET( const httpModule = parsed.protocol === 'https:' ? https : http; return new Promise((resolve, reject) => { + if (lback && lback >= 5) { + return reject(new Error('infinite loop!')); + } + const req = httpModule.get(opts, (res) => { if (res.statusCode === 302 || res.statusCode === 301) { if (!lback) {