MCPcopy
hub / github.com/colbymchenry/codegraph / onDaemonLost

Function onDaemonLost

src/mcp/proxy.ts:367–378  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

365 // hang. Instead, fall back to the in-process engine for the rest of the
366 // session and re-serve whatever the dead daemon never answered.
367 const onDaemonLost = (): void => {
368 if (shuttingDown || daemonStatus !== 'ready') return; // host teardown, or already handled
369 daemonStatus = 'failed';
370 try { daemonSocket?.destroy(); } catch { /* ignore */ }
371 daemonSocket = null;
372 process.stderr.write(
373 `[CodeGraph MCP] Shared daemon connection lost; serving this session in-process (degraded), re-serving ${inflight.size} in-flight request(s).\n`
374 );
375 const orphaned = [...inflight.values()];
376 inflight.clear();
377 for (const line of orphaned) void handleLocally(line);
378 };
379 socket.on('close', onDaemonLost);
380 socket.on('error', onDaemonLost);
381 for (const line of pending) { trackInflight(line); try { socket.write(line + '\n'); } catch { /* ignore */ } }

Callers

nothing calls this directly

Calls 4

handleLocallyFunction · 0.85
destroyMethod · 0.45
writeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected