()
| 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 */ } } |
nothing calls this directly
no test coverage detected