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

Method terminateStarted

src/mcp/query-pool.ts:492–503  ·  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

490 * see that constant for the crash this avoids).
491 */
492 private async terminateStarted(w: PoolWorker): Promise<void> {
493 const start = this.starts.get(w);
494 if (start) {
495 let cap: NodeJS.Timeout | undefined;
496 await Promise.race([
497 start.settled,
498 new Promise<void>((resolve) => { cap = setTimeout(resolve, this.startSettleMs); cap.unref?.(); }),
499 ]);
500 clearTimeout(cap);
501 }
502 try { await w.terminate(); } catch { /* already gone */ }
503 }
504
505 /**
506 * 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