MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / finalizeDaemonExit

Function finalizeDaemonExit

src/mcp/daemon.ts:95–110  ·  view source on GitHub ↗
(
  platform: NodeJS.Platform,
  exit: (code: number) => void,
)

Source from the content-addressed store, hash-verified

93 * so callers/tests can clear it.
94 */
95export function finalizeDaemonExit(
96 platform: NodeJS.Platform,
97 exit: (code: number) => void,
98): NodeJS.Timeout | null {
99 if (platform === 'win32') {
100 process.exitCode = 0;
101 const backstop = setTimeout(() => exit(0), DAEMON_SHUTDOWN_BACKSTOP_MS);
102 // Unref so it never keeps the loop alive: a natural drain (watchers closed,
103 // nothing else pending) exits before it fires; it only fires when some other
104 // handle is keeping the loop running, which is exactly when we need it.
105 backstop.unref?.();
106 return backstop;
107 }
108 exit(0);
109 return null;
110}
111
112/** How often the daemon sweeps connected clients for a dead peer process (#692). */
113const DEFAULT_CLIENT_SWEEP_MS = 30_000;

Callers 2

stopMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected