Terminate all workers and answer any outstanding calls gracefully.
()
| 310 | |
| 311 | /** Terminate all workers and answer any outstanding calls gracefully. */ |
| 312 | async destroy(): Promise<void> { |
| 313 | if (this.destroyed) return; |
| 314 | this.destroyed = true; |
| 315 | const ws = [...this.workers]; |
| 316 | this.workers.clear(); |
| 317 | this.pendingWorkers.clear(); |
| 318 | this.idle = []; |
| 319 | for (const job of [...this.inflight.values(), ...this.queue]) { |
| 320 | this.settle(job, { isError: true, content: [{ type: 'text', text: 'codegraph is shutting down; retry shortly.' }] }); |
| 321 | } |
| 322 | this.inflight.clear(); |
| 323 | this.queue = []; |
| 324 | await Promise.all(ws.map((w) => Promise.resolve(w.terminate()).catch(() => { /* already gone */ }))); |
| 325 | } |
| 326 | } |
no test coverage detected