Terminate all workers and answer any outstanding calls gracefully.
()
| 292 | |
| 293 | /** Terminate all workers and answer any outstanding calls gracefully. */ |
| 294 | async destroy(): Promise<void> { |
| 295 | if (this.destroyed) return; |
| 296 | this.destroyed = true; |
| 297 | const ws = [...this.workers]; |
| 298 | this.workers.clear(); |
| 299 | this.pendingWorkers.clear(); |
| 300 | this.idle = []; |
| 301 | for (const job of [...this.inflight.values(), ...this.queue]) { |
| 302 | this.settle(job, { isError: true, content: [{ type: 'text', text: 'codegraph is shutting down; retry shortly.' }] }); |
| 303 | } |
| 304 | this.inflight.clear(); |
| 305 | this.queue = []; |
| 306 | await Promise.all(ws.map((w) => Promise.resolve(w.terminate()).catch(() => { /* already gone */ }))); |
| 307 | } |
| 308 | } |
no test coverage detected