MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / terminateStarted

Method terminateStarted

src/mcp/query-pool.ts:505–516  ·  view source on GitHub ↗

* Terminate a worker, but not while it is still starting up: wait for it to * post 'ready' (or go away), up to `startSettleMs` (WORKER_START_SETTLE_MS — * see that constant for the crash this avoids).

(w: PoolWorker)

Source from the content-addressed store, hash-verified

503 * see that constant for the crash this avoids).
504 */
505 private async terminateStarted(w: PoolWorker): Promise<void> {
506 const start = this.starts.get(w);
507 if (start) {
508 let cap: NodeJS.Timeout | undefined;
509 await Promise.race([
510 start.settled,
511 new Promise<void>((resolve) => { cap = setTimeout(resolve, this.startSettleMs); cap.unref?.(); }),
512 ]);
513 clearTimeout(cap);
514 }
515 try { await w.terminate(); } catch { /* already gone */ }
516 }
517
518 /**
519 * Terminate all workers and answer any outstanding calls gracefully. A worker

Callers 2

terminateMethod · 0.95
destroyMethod · 0.95

Calls 2

getMethod · 0.65
terminateMethod · 0.65

Tested by

no test coverage detected