{"record":{"id":"1f09169fcbde4928","repo":"diegosouzapw/OmniRoute","slug":"bad-gateway-1f0916","errorCode":null,"errorMessage":"Bad Gateway","messagePattern":"Bad Gateway","errorType":"http","errorClass":null,"httpStatus":502,"severity":"error","filePath":"src/mitm/tproxy/tlsCapture.ts","lineNumber":219,"sourceCode":"      intercepted.proxyLatencyMs = 0;\n\n      const safeRespHeaders: Record<string, string> = {};\n      for (const [k, v] of Object.entries(result.headers)) {\n        const lk = k.toLowerCase();\n        if (lk === \"content-length\" || lk === \"transfer-encoding\") continue;\n        safeRespHeaders[k] = v;\n      }\n      res.writeHead(result.status, safeRespHeaders);\n      res.end(result.body);\n\n      deps.buffer.update(intercepted.id, intercepted);\n    } catch (err) {\n      intercepted.status = \"error\";\n      intercepted.error = sanitizeErrorMessage(err);\n      intercepted.totalLatencyMs = deps.now() - startedAt;\n      deps.buffer.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\nexport interface TlsCaptureServer {\n  /** Internal HTTP server that parses the decrypted plaintext. */\n  server: http.Server;\n  /** TLS-terminate a raw intercepted socket and capture/forward the exchange. */\n  terminate(rawClient: net.Socket, dest: DecryptedDest): void;\n  /** Close the internal server. */\n  close(): Promise<void>;\n}\n\n/**","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/mitm/tproxy/tlsCapture.ts#L201-L237","documentation":"Error \"Bad Gateway\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/mitm/tproxy/tlsCapture.ts:219 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"}