docmirror/dev-sidecar · warning
server process exit, code: ${code}, signal:
Error message
server process exit, code: ${code}, signal: What it means
A warning log from the `exit` handler on the forked mitmproxy child process (packages/core/src/modules/server/index.js:121-123). It reports that the child process has terminated, including the exit code (or null) and, when terminated by a signal, the signal name. This is the definitive lifecycle event telling the parent the proxy server is no longer running.
Source
Thrown at packages/core/src/modules/server/index.js:122
throw e
}
const serverProcess = fork(mitmproxyPath, [runningConfigPath])
server = {
id: serverProcess.pid,
process: serverProcess,
port: serverConfig.port,
close () {
serverProcess.send({ type: 'action', event: { key: 'close' } })
},
}
serverProcess.on('beforeExit', (code) => {
log.warn('server process beforeExit, code:', code)
})
serverProcess.on('SIGPIPE', (code, signal) => {
log.warn(`server process SIGPIPE, code: ${code}, signal:`, signal)
})
serverProcess.on('exit', (code, signal) => {
log.warn(`server process exit, code: ${code}, signal:`, signal)
})
serverProcess.on('uncaughtException', (err, origin) => {
log.error('server process uncaughtException:', err)
})
serverProcess.on('message', (msg) => {
log.debug('收到子进程消息:', JSON.stringify(msg))
if (msg.type === 'status') {
fireStatus(msg.event)
} else if (msg.type === 'error') {
let code = ''
if (msg.event.code) {
code = msg.event.code
}
fireStatus(false) // 启动失败
event.fire('error', { key: 'server', value: code, error: msg.event, message: msg.message })
} else if (msg.type === 'speed') {
event.fire('speed', msg.event)
}View on GitHub (pinned to 7710cd56cc)
Solutions
- If exit code is 0 or signal is SIGINT and you called close/kill/restart, this is expected — ignore.
- For unexpected exits, read `~/.dev-sidecar/logs/server.log` and core.log for the error printed just before exit (EADDRINUSE, config parse failure, uncaughtException).
- If killed by SIGKILL, check system memory/OOM killer logs (dmesg) and reduce child memory usage.
- Add restart logic: on non-zero exit without a pending shutdown, call serverApi.restart({ mitmproxyPath }) to restore the proxy.
- Confirm the mitmproxyPath points to the correct entry of the installed @docmirror/mitmproxy version.
Example fix
// before
serverProcess.on('exit', (code, signal) => {
log.warn(`server process exit, code: ${code}, signal:`, signal)
})
// after
serverProcess.on('exit', (code, signal) => {
log.warn(`server process exit, code: ${code}, signal:`, signal)
if (code !== 0 && !shuttingDown) {
log.error('server crashed unexpectedly, restarting')
setTimeout(() => serverApi.restart({ mitmproxyPath }), 2000)
}
}) Defensive patterns
Strategy: fallback
Validate before calling
// avoid broken stdout pipes in headless/daemon environments
if (!process.stdout.isTTY && process.env.DAEMON_MODE) {
process.env.DEV_SIDECAR_LOG_TO_CONSOLE = 'false' // file-only logging, no stdout pipe to break
} Try / catch
try {
serverProcess.write(streamData)
} catch (e) {
if (e.code === 'EPIPE') {
log.warn('child pipe closed; falling back to file logging')
switchToFileLogging()
}
} Prevention
- Shut down the child (server.close()) before the parent exits so IPC/stdout pipes close cleanly.
- Run daemons with DEV_SIDECAR_LOG_TO_CONSOLE=false so logs go to files, not fragile terminal pipes.
- Don't kill the GUI/CLI parent with SIGKILL; use graceful shutdown to avoid orphaned children with dead pipes.
- Attach error handlers on child stdout/stderr streams to absorb EPIPE instead of crashing.
When it happens
Trigger: Calling server.close()/kill() (SIGINT, line 146); the child crashes (non-zero exit code or signal like SIGSEGV/SIGKILL); the child calls process.exit after an uncaughtException; the OS kills the process (OOM killer).
Common situations: Intentional shutdown shows code 0 / SIGINT; crash loops show repeated non-zero codes — often port already in use (EADDRINUSE), invalid running.json, or missing native module in the child; OOM kills show signal SIGKILL under memory pressure.
Related errors
- server process beforeExit, code:
- server process SIGPIPE, code: ${code}, signal:
- 未指定日志类型,无法配置并获取日志对象!!!
- sub Process SIGPIPE
AI-assisted analysis of docmirror/dev-sidecar@7710cd56cc (2026-08-31).
Data as JSON: /api/errors/30ee944a1e107b4a.
Report an issue: GitHub.