{"record":{"id":"a6e4fc7950fe63e2","repo":"diegosouzapw/OmniRoute","slug":"bad-gateway","errorCode":null,"errorMessage":"Bad Gateway","messagePattern":"Bad Gateway","errorType":"http","errorClass":null,"httpStatus":502,"severity":"error","filePath":"src/mitm/inspector/httpProxyServer.ts","lineNumber":162,"sourceCode":"      intercepted.proxyLatencyMs = 0;\n\n      const safeRespHeaders: Record<string, string> = {};\n      upstream.headers.forEach((value, key) => {\n        if (key.toLowerCase() === \"content-length\") return;\n        if (key.toLowerCase() === \"transfer-encoding\") return;\n        safeRespHeaders[key] = value;\n      });\n      res.writeHead(upstream.status, safeRespHeaders);\n      res.end(respBuf);\n\n      globalTrafficBuffer.update(intercepted.id, intercepted);\n    } catch (err) {\n      intercepted.status = \"error\";\n      intercepted.error = sanitizeErrorMessage(err);\n      intercepted.totalLatencyMs = performance.now() - startedAt;\n      globalTrafficBuffer.update(intercepted.id, intercepted);\n      if (!res.headersSent) {\n        res.writeHead(502, { \"content-type\": \"text/plain\" });\n        res.end(\"Bad Gateway\");\n      } else {\n        res.end();\n      }\n    }\n  })();\n}\n\nfunction handleConnect(\n  req: http.IncomingMessage,\n  clientSocket: net.Socket,\n  head: Buffer\n): void {\n  const target = req.url ?? \"\";\n  const [host, rawPort] = target.split(\":\");\n  const port = Number(rawPort) || 443;\n\n  const intercepted: InterceptedRequest = {","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/mitm/inspector/httpProxyServer.ts#L144-L180","documentation":"Error \"Bad Gateway\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/mitm/inspector/httpProxyServer.ts:162 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}