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

Method retire

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

* Ask an idle worker to exit by itself: it closes its connections and * collects garbage first, so no marking is in flight when its thread ends * (see worker-teardown.ts). One that hasn't exited by `retireTimeoutMs` is * terminated.

(w: PoolWorker)

Source from the content-addressed store, hash-verified

411 * terminated.
412 */
413 private retire(w: PoolWorker): void {
414 const terminate = (): void => { void this.terminateStarted(w).then(() => this.retired(w)); };
415 const cap = setTimeout(terminate, this.retireTimeoutMs);
416 cap.unref?.();
417 let settle!: () => void;
418 const gone = new Promise<void>((resolve) => { settle = resolve; });
419 this.retiring.set(w, { cap, gone, settle });
420 try {
421 w.postMessage({ type: 'close' });
422 } catch {
423 clearTimeout(cap);
424 terminate();
425 }
426 }
427
428 private retired(w: PoolWorker): void {
429 const retirement = this.retiring.get(w);

Callers 2

shrinkIdleMethod · 0.95
replaceIfHeavyMethod · 0.95

Calls 2

postMessageMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected