mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-13 11:00:50 +00:00
* fix(gateway): handle async EPIPE on stdout/stderr during shutdown The console capture forward() wrapper catches synchronous EPIPE errors, but when the receiving pipe closes during shutdown Node emits the error asynchronously on the stream. Without a listener this becomes an uncaught exception that crashes the gateway, causing macOS launchd to permanently unload the service. Add error listeners on process.stdout and process.stderr inside enableConsoleCapture() that silently swallow EPIPE/EIO (matching the existing isEpipeError helper) and re-throw anything else. Closes #13367 * guard stream error listeners against repeated enableConsoleCapture() calls Use a separate streamErrorHandlersInstalled flag in loggingState so that test resets of consolePatched don't cause listener accumulation on process.stdout/stderr.
19 lines
554 B
TypeScript
19 lines
554 B
TypeScript
export const loggingState = {
|
|
cachedLogger: null as unknown,
|
|
cachedSettings: null as unknown,
|
|
cachedConsoleSettings: null as unknown,
|
|
overrideSettings: null as unknown,
|
|
consolePatched: false,
|
|
forceConsoleToStderr: false,
|
|
consoleTimestampPrefix: false,
|
|
consoleSubsystemFilter: null as string[] | null,
|
|
resolvingConsoleSettings: false,
|
|
streamErrorHandlersInstalled: false,
|
|
rawConsole: null as {
|
|
log: typeof console.log;
|
|
info: typeof console.info;
|
|
warn: typeof console.warn;
|
|
error: typeof console.error;
|
|
} | null,
|
|
};
|