{"record":{"id":"b80cd88bd58dbaf3","repo":"docmirror/dev-sidecar","slug":"sub-process-sigpipe","errorCode":null,"errorMessage":"sub Process SIGPIPE","messagePattern":"sub Process SIGPIPE","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/mitmproxy/src/index.js","lineNumber":118,"sourceCode":"    }\n    log.error('Process uncaughtException:', err)\n  })\n\n  process.on('unhandledRejection', (err, p) => {\n    log.info('Process unhandledRejection at: Promise', p, 'err:', err)\n    // application specific logging, throwing an error, or other logic here\n  })\n  process.on('uncaughtExceptionMonitor', (err, origin) => {\n    log.info('Process uncaughtExceptionMonitor:', err, origin)\n  })\n  process.on('exit', (code, signal) => {\n    log.info('代理服务进程被关闭:', code, signal)\n  })\n  process.on('beforeExit', (code, signal) => {\n    log.info('Process beforeExit event with code: ', code, signal)\n  })\n  process.on('SIGPIPE', (code, signal) => {\n    log.warn('sub Process SIGPIPE', code, signal)\n  })\n}\n\nmodule.exports = {\n  ...api,\n  config: proxyConfig,\n  log,\n  speedTest,\n}\n","sourceCodeStart":100,"sourceCodeEnd":128,"githubUrl":"https://github.com/docmirror/dev-sidecar/blob/7710cd56cce760c708f30b01d2d4056eb8c402d5/packages/mitmproxy/src/index.js#L100-L128","documentation":"The mitmproxy child process logs a SIGPIPE signal received by the Node process. SIGPIPE occurs when the process writes to a pipe whose read end has been closed (e.g. stdout piped to a tool that exited). Node normally suppresses SIGPIPE for its own streams; receiving it here means an external writer/pipe consumer disappeared. This handler logs a warning instead of crashing.","triggerScenarios":"Running the proxy process with stdout/stderr piped into another process (e.g. `node index.js | head`, systemd/journal rotation, Docker log driver closing) and that consumer exits while the proxy keeps writing logs via log4js stdout appender.","commonSituations":"CLI usage piping proxy output; daemon supervisors that detach pipes; Docker containers with closed log pipes; CI jobs that truncate output.","solutions":["Set DEV_SIDECAR_LOG_TO_CONSOLE=false so logs go to file only and the process never writes to the broken pipe.","Ensure the pipe consumer (e.g. `| tee`, `| head`) stays alive or remove the pipe and redirect to a file instead.","If running under systemd/Docker, configure log rotation (RotateMax, json-file max-size) so pipes are not closed mid-run.","Ignore the warning if it appears once at shutdown; it is non-fatal by design."],"exampleFix":"// before\nnode server.js | grep proxy\n// after\nDEV_SIDECAR_LOG_TO_CONSOLE=false node server.js   # logs only to ~/.dev-sidecar/logs","handlingStrategy":"fallback","validationCode":"if (!process.stdout.writable) { process.env.DEV_SIDECAR_LOG_TO_CONSOLE = 'false' }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run with DEV_SIDECAR_LOG_TO_CONSOLE=false in daemon/piped environments","Redirect output to files instead of pipes whose consumers may exit early","Configure log rotation in supervisors (logrotate, Docker json-file max-size)"],"tags":["sigpipe","process","logging","pipe"],"backgroundTag":"broken-pipe-sigpipe","analyzedSha":"7710cd56cce760c708f30b01d2d4056eb8c402d5","analyzedAt":"2026-08-31T22:07:07.234Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}