()
| 368 | // Stop the in-process engine once the calls it is serving have answered. |
| 369 | // Stopping it releases the writer lock if it held one. |
| 370 | const retireEngine = async (): Promise<void> => { |
| 371 | const retired = engine; |
| 372 | engine = null; |
| 373 | engineReady = null; |
| 374 | if (retired) retiring.add(retired); |
| 375 | try { |
| 376 | await Promise.allSettled([...localCalls]); |
| 377 | try { await retired?.stop(); } catch { /* best-effort */ } |
| 378 | } finally { |
| 379 | if (retired) retiring.delete(retired); |
| 380 | } |
| 381 | }; |
| 382 | // Daemon-unavailable fallback: serve a client message in-process. |
| 383 | const handleLocally = (line: string): Promise<void> => { |
| 384 | const call = serveLocally(line); |
no test coverage detected