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

Method reapDeadClients

src/mcp/daemon.ts:484–498  ·  view source on GitHub ↗

* Drop every connected client whose peer process is gone. Returns the count * reaped. `isAlive` is injected for testing. Clients with unknown pids (no * client-hello) are skipped — they rely on the socket-close path.

(isAlive: (pid: number) => boolean)

Source from the content-addressed store, hash-verified

482 * client-hello) are skipped — they rely on the socket-close path.
483 */
484 reapDeadClients(isAlive: (pid: number) => boolean): number {
485 if (this.clients.size === 0) return 0;
486 let reaped = 0;
487 for (const session of [...this.clients]) {
488 const peers = this.clientPeers.get(session);
489 if (!peers || !peerIsDead(peers, isAlive)) continue;
490 process.stderr.write(
491 `[CodeGraph daemon] Reaping client with dead peer (pid ${peers.pid}); clients=${this.clients.size - 1}.\n`
492 );
493 try { session.stop(); } catch { /* best-effort */ }
494 this.dropClient(session);
495 reaped++;
496 }
497 return reaped;
498 }
499
500 private cleanupLockfile(): void {
501 try {

Callers 3

startLivenessTimersMethod · 0.95
backstopShouldExitMethod · 0.95

Calls 5

dropClientMethod · 0.95
peerIsDeadFunction · 0.85
getMethod · 0.65
stopMethod · 0.65
writeMethod · 0.45

Tested by

no test coverage detected