docmirror/dev-sidecar · warning

sub Process SIGPIPE

Error message

sub Process SIGPIPE

What it means

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.

Source

Thrown at packages/mitmproxy/src/index.js:118

    }
    log.error('Process uncaughtException:', err)
  })

  process.on('unhandledRejection', (err, p) => {
    log.info('Process unhandledRejection at: Promise', p, 'err:', err)
    // application specific logging, throwing an error, or other logic here
  })
  process.on('uncaughtExceptionMonitor', (err, origin) => {
    log.info('Process uncaughtExceptionMonitor:', err, origin)
  })
  process.on('exit', (code, signal) => {
    log.info('代理服务进程被关闭:', code, signal)
  })
  process.on('beforeExit', (code, signal) => {
    log.info('Process beforeExit event with code: ', code, signal)
  })
  process.on('SIGPIPE', (code, signal) => {
    log.warn('sub Process SIGPIPE', code, signal)
  })
}

module.exports = {
  ...api,
  config: proxyConfig,
  log,
  speedTest,
}

View on GitHub (pinned to 7710cd56cc)

Solutions

  1. Set DEV_SIDECAR_LOG_TO_CONSOLE=false so logs go to file only and the process never writes to the broken pipe.
  2. Ensure the pipe consumer (e.g. `| tee`, `| head`) stays alive or remove the pipe and redirect to a file instead.
  3. If running under systemd/Docker, configure log rotation (RotateMax, json-file max-size) so pipes are not closed mid-run.
  4. Ignore the warning if it appears once at shutdown; it is non-fatal by design.

Example fix

// before
node server.js | grep proxy
// after
DEV_SIDECAR_LOG_TO_CONSOLE=false node server.js   # logs only to ~/.dev-sidecar/logs
Defensive patterns

Strategy: fallback

Validate before calling

if (!process.stdout.writable) { process.env.DEV_SIDECAR_LOG_TO_CONSOLE = 'false' }

Prevention

When it happens

Trigger: 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.

Common situations: CLI usage piping proxy output; daemon supervisors that detach pipes; Docker containers with closed log pipes; CI jobs that truncate output.

Related errors


AI-assisted analysis of docmirror/dev-sidecar@7710cd56cc (2026-08-31). Data as JSON: /api/errors/b80cd88bd58dbaf3. Report an issue: GitHub.