* Terminate all workers and answer any outstanding calls gracefully. A worker * still starting up is terminated once it has started (see * WORKER_START_SETTLE_MS); outstanding calls are answered first.
()
| 367 | * WORKER_START_SETTLE_MS); outstanding calls are answered first. |
| 368 | */ |
| 369 | async destroy(): Promise<void> { |
| 370 | if (this.destroyed) return; |
| 371 | this.destroyed = true; |
| 372 | const ws = [...this.workers]; |
| 373 | this.workers.clear(); |
| 374 | this.pendingWorkers.clear(); |
| 375 | this.idle = []; |
| 376 | for (const job of [...this.inflight.values(), ...this.queue]) { |
| 377 | this.settle(job, { isError: true, content: [{ type: 'text', text: 'codegraph is shutting down; retry shortly.' }] }); |
| 378 | } |
| 379 | this.inflight.clear(); |
| 380 | this.queue = []; |
| 381 | await Promise.all(ws.map((w) => this.terminateStarted(w))); |
| 382 | } |
| 383 | } |
no test coverage detected