()
| 382 | // hang. Instead, fall back to the in-process engine for the rest of the |
| 383 | // session and re-serve whatever the dead daemon never answered. |
| 384 | const onDaemonLost = (): void => { |
| 385 | if (shuttingDown || daemonStatus !== 'ready') return; // host teardown, or already handled |
| 386 | daemonStatus = 'failed'; |
| 387 | try { daemonSocket?.destroy(); } catch { /* ignore */ } |
| 388 | daemonSocket = null; |
| 389 | process.stderr.write( |
| 390 | `[CodeGraph MCP] Shared daemon connection lost; serving this session in-process (degraded), re-serving ${inflight.size} in-flight request(s).\n` |
| 391 | ); |
| 392 | const orphaned = [...inflight.values()]; |
| 393 | inflight.clear(); |
| 394 | for (const line of orphaned) void handleLocally(line); |
| 395 | }; |
| 396 | socket.on('close', onDaemonLost); |
| 397 | socket.on('error', onDaemonLost); |
| 398 | for (const line of pending) { |
nothing calls this directly
no test coverage detected