{"record":{"id":"992a9af0c8245171","repo":"docmirror/dev-sidecar","slug":"fakeserver-stream-error-hostname-port","errorCode":null,"errorMessage":"【fakeServer stream error - ${hostname}:${port}】","messagePattern":"【fakeServer stream error - (.+?):(.+?)】","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/mitmproxy/src/lib/proxy/tls/FakeServersCenter.js","lineNumber":194,"sourceCode":"        // 三个 error 事件\n        fakeServer.on('error', (e) => {\n          log.error(`【fakeServer error - ${hostname}:${port}】\\r\\n----- error -----\\r\\n`, e)\n          if (!isListening) {\n            reject(e)\n          }\n        })\n        // HTTP/2 会话错误：协议违规、帧错误等\n        fakeServer.on('sessionError', (err, session) => {\n          log.error(`【fakeServer sessionError - ${hostname}:${port}】`, err)\n        })\n        // HTTP/2 会话建立：绑定流错误监听，避免未捕获异常\n        fakeServer.on('session', (session) => {\n          session.on('error', (err) => {\n            log.warn(`【fakeServer session error - ${hostname}:${port}】`, err)\n          })\n          session.on('stream', (stream) => {\n            stream.on('error', (err) => {\n              log.warn(`【fakeServer stream error - ${hostname}:${port}】`, err)\n            })\n          })\n        })\n        fakeServer.on('clientError', (err, _socket) => {\n          // log.error(`【fakeServer clientError - ${hostname}:${port}】\\r\\n----- error -----\\r\\n`, err, '\\r\\n----- socket -----\\r\\n', socket)\n          log.error(`【fakeServer clientError - ${hostname}:${port}】\\r\\n`, err)\n\n          // 自动兼容程序：1\n          if (port !== 443 && port !== 80) {\n            if (ssl === true && err.code && err.code.startsWith('ERR_SSL_')) {\n              compatible.setConnectSsl(hostname, port, false)\n              log.error(`自动兼容程序：SSL异常，现设置为禁用ssl: ${hostname}:${port}, ssl = false`)\n            } else if (ssl === false && err.code === 'HPE_INVALID_METHOD') {\n              compatible.setConnectSsl(hostname, port, true)\n              log.error(`自动兼容程序：${err.code}，现设置为启用ssl: ${hostname}:${port}, ssl = true`)\n            }\n          }\n        })","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/docmirror/dev-sidecar/blob/7710cd56cce760c708f30b01d2d4056eb8c402d5/packages/mitmproxy/src/lib/proxy/tls/FakeServersCenter.js#L176-L212","documentation":"A log.warn from the per-stream error handler on HTTP/2 sessions of the fake MITM server. Individual h2 streams (requests) that fail — e.g. reset by the client (RST_STREAM), protocol errors, or aborted downloads — are logged here so the proxy keeps serving instead of throwing. The message is per-request, not per-server.","triggerScenarios":"Any h2 request/stream on the fake server for hostname:port errors: client cancels a download, RST_STREAM on navigation away, request aborted before response completes, or protocol-level violation after the session was established.","commonSituations":"User navigates away mid-download (ERR_ABORTED equivalents), page loads canceled by the browser, video streams interrupted; very common and normally harmless during normal browsing through the proxy.","solutions":["Ignore if browsing works — stream errors from canceled requests are expected","If a specific site consistently fails, look at the following err object in server.log to identify the stream error code","Retry the failing request; transient resets often self-heal","If persistent, try forcing HTTP/1.1 for that domain or check for mitm/intercept rules mangling the response"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"stream.on('error', (err) => {\n  if (err.code === 'ERR_HTTP2_STREAM_ERROR' || err.code === 'ECONNRESET') {\n    log.debug('h2 stream aborted by client; safe to ignore')\n    return\n  }\n  log.warn('unexpected h2 stream error', err)\n})","preventionTips":["Treat canceled navigation mid-download as normal — don't alert on every stream warn","If one site streams errors consistently, test it with HTTP/1.1 or outside the proxy","Keep mitmproxy updated: h2 stream handling fixes land in newer versions","Review server.log error codes (RST_STREAM, ERR_HTTP2_PROTOCOL_ERROR) to spot real protocol issues"],"tags":["http2","stream","mitm"],"backgroundTag":"http2-stream-error","analyzedSha":"7710cd56cce760c708f30b01d2d4056eb8c402d5","analyzedAt":"2026-08-31T22:07:07.234Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}