/** * Exit status for "our output pipe is gone". 128 + SIGPIPE(13), the shell * convention for death by broken pipe, so a supervisor can tell this apart * from an ordinary crash. */ export declare const BROKEN_PIPE_EXIT_CODE = 141; /** Structural subset of `process.stdout` the safety net inspects and watches. */ type StdioStream = { destroyed?: boolean; writableEnded?: boolean; on?: (event: "error", listener: (err: unknown) => void) => unknown; off?: (event: "error", listener: (err: unknown) => void) => unknown; }; export interface SafetyNetOptions { /** Emits the non-fatal diagnostic line. Routed through the LogStore. */ log: (line: string) => void; /** Terminates the process. Defaults to `process.exit`. */ exit?: (code: number) => void; /** Stream whose death makes logging pointless. Defaults to `process.stdout`. */ stdout?: StdioStream; /** * Exit when the output pipe dies. Default `true` here, but the caller * decides: only code that owns the process should pass `true`. See * `ServeOptions.exitOnBrokenPipe`, which defaults to `false` for that * reason. Silencing the sinks is unaffected either way. */ exitOnBrokenPipe?: boolean; } export type SafetyNetHandler = (label: "uncaughtException" | "unhandledRejection", err: unknown) => void; /** * Build the handler shared by both process-level listeners. * * Exposed separately from {@link installProcessSafetyNet} so its policy can be * tested without registering real listeners on the test runner's process. */ export declare function createSafetyNetHandler(opts: SafetyNetOptions): SafetyNetHandler; /** * Claim the output stream's `error` event. Returns an uninstall function. * * This is its sole owner — sinks stay passive readers of the shared * broken-stream mark, because claiming the event suppresses Node's fatal-EPIPE * exit and a CLI piped into `head` still needs it. Claiming it here is what * keeps the failure out of `uncaughtException`, and so out of the log sink * that raised it. Install as early as there is a stream to watch: it carries * the whole broken-pipe guarantee on its own. */ export declare function watchOutputStream(opts: Omit): () => void; /** * Register the `uncaughtException` / `unhandledRejection` listeners, which * downgrade a stray async error from fatal to logged. Returns an uninstall * function; call it when the server shuts down, or an in-process host that * starts several servers accumulates listener sets. * * Install this only once startup has succeeded. Downgrading during boot means * a failure before the transport listens no longer stops the process, and it * would go on reporting healthy (the process targets check liveness by pid) * for a server that never came up. */ export declare function installProcessSafetyNet(opts: SafetyNetOptions): () => void; export {}; //# sourceMappingURL=process-safety-net.d.ts.map