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

Function connectDaemon

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

Source from the content-addressed store, hash-verified

499
500 // ---- daemon connection (background) ----
501 const connectDaemon = async (): Promise<net.Socket | null> => {
502 let socket: net.Socket | null = null;
503 try { socket = await deps.getDaemonSocket(); } catch { socket = null; }
504 // `socket.destroyed`: the connect-window error guard above can absorb an
505 // 'error' that already destroyed the socket before we got here (#974) — treat
506 // a dead socket as "no daemon" so we cleanly fall back to the in-process engine.
507 if (socket && (socket.destroyed || shuttingDown)) {
508 try { socket.destroy(); } catch { /* ignore */ }
509 socket = null;
510 }
511 return socket;
512 };
513 // Every buffered call binds to the engine now, so a later retirement waits for all of them.
514 const serveBufferedLocally = (): void => {
515 for (const line of pending.splice(0)) void handleLocally(line);

Callers 2

retryDaemonFunction · 0.85
runLocalHandshakeProxyFunction · 0.85

Calls 2

getDaemonSocketMethod · 0.65
destroyMethod · 0.45

Tested by

no test coverage detected