{"record":{"id":"c2ed6b356190a13d","repo":"qeeqbox/social-analyzer","slug":"error-get-url","errorCode":"error-get-url","errorMessage":"error-get-url","messagePattern":"error-get-url","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/helper.js","lineNumber":232,"sourceCode":"          data: ''\n        })\n      })\n      request.on('socket', function (socket) {\n        const timeout = (time !== 0) ? time * 1000 : 5000\n        socket.setTimeout(timeout, function () {\n          request.abort()\n        })\n      })\n    })\n    const response_body = await http_promise\n    return response_body\n  } catch (err) {\n    verbose && console.log(err)\n  }\n}\n\nasync function get_url_wrapper_text (url, time = 2) {\n  const response_body = 'error-get-url'\n  const ret = 500\n  try {\n    const http_promise = new Promise((resolve, reject) => {\n      const request = https.https.get(url, header_options, function (res) {\n        let body = ''\n        res.on('data', function (chunk) {\n          body += chunk\n        })\n        res.on('end', function () {\n          resolve([res.statusCode,body])\n        })\n      })\n      const timeout = (time !== 0) ? time * 1000 : 5000\n      request.setTimeout(timeout, function() {\n        reject({\n          data: ''\n        })\n      });","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/qeeqbox/social-analyzer/blob/1ba0905e00d054aab833eb3693739c354db09e0f/modules/helper.js#L214-L250","documentation":"modules/helper.js get_url_wrapper_text is a thin HTTPS GET helper that returns the literal sentinel string 'error-get-url' (with HTTP 500) whenever the https.get request fails. It is not a thrown Error object but a fallback return value produced by the catch block after request error, timeout, or abort. Callers must compare the returned status/body against this sentinel to detect failure.","triggerScenarios":"Calling get_url_wrapper_text(url) where the HTTPS request emits 'error' (DNS failure, connection refused/refused TLS handshake), the timeout (time*1000 ms, default 2s, or 5s if time===0) fires and calls request.abort(), or the promise rejects with {data:''}.","commonSituations":"Scanning usernames against sites that are down, rate-limited, or block non-browser agents; invalid or unreachable URLs; too-short timeout (default 2s) on slow sites; no network / proxy issues; sites requiring TLS versions the default agent rejects.","solutions":["Check the return value for the 'error-get-url' sentinel (and status 500) before parsing the body","Increase the time parameter (e.g. get_url_wrapper_text(url, 10)) to avoid premature timeouts on slow sites","Verify the URL is reachable (curl/DNS) and correct; test with a fresh API key or proxy if the site blocks the default header_options","Confirm outbound HTTPS connectivity (no corporate proxy/firewall blocking Node)"],"exampleFix":"// before\nconst [status, body] = await get_url_wrapper_text(url)\nJSON.parse(body)\n// after\nconst ret = await get_url_wrapper_text(url, 10)\nif (ret[0] === 500 && ret[1] === 'error-get-url') {\n  // handle failed fetch: skip site / retry\n} else {\n  JSON.parse(ret[1])\n}","handlingStrategy":"fallback","validationCode":"const urlObj = new URL(url)\nif (urlObj.protocol !== 'https:') throw new Error('expected https url')\n// optional reachability pre-check\nconst ok = await new Promise(r => { const req = require('https').request(urlObj, {method:'HEAD', timeout:5000}, res => r(res.statusCode < 500)); req.on('error', () => r(false)); req.on('timeout', () => { req.destroy(); r(false) }); req.end() })\nif (!ok) console.warn('site likely unreachable, expect error-get-url')","typeGuard":"function isFetchFailure(ret) {\n  return Array.isArray(ret) && ret[0] === 500 && ret[1] === 'error-get-url'\n}","tryCatchPattern":"const ret = await get_url_wrapper_text(url, 10)\nif (isFetchFailure(ret)) {\n  // fallback: mark site unreachable, skip or queue retry\n} else {\n  const [status, body] = ret\n  // consume status/body safely\n}","preventionTips":["Always compare the result against the 'error-get-url' sentinel before parsing JSON","Pass a generous time argument (>=5s) since the default 2s timeout aborts slow sites","Pre-validate URLs with new URL() and check https protocol","Wrap external calls in retry logic with backoff for transient network failures"],"tags":["network","http","timeout","sentinel-value"],"backgroundTag":"http-request-failed","analyzedSha":"1ba0905e00d054aab833eb3693739c354db09e0f","analyzedAt":"2026-08-31T21:42:26.566Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}