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

Method retire

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

381 * terminated.
382 */
383 private retire(w: PoolWorker): void {
384 const terminate = (): void => { void this.terminateStarted(w).then(() => this.retired(w)); };
385 const cap = setTimeout(terminate, this.retireTimeoutMs);
386 cap.unref?.();
387 let settle!: () => void;
388 const gone = new Promise<void>((resolve) => { settle = resolve; });
389 this.retiring.set(w, { cap, gone, settle });
390 try {
391 w.postMessage({ type: 'close' });
392 } catch {
393 clearTimeout(cap);
394 terminate();
395 }
396 }
397
398 private retired(w: PoolWorker): void {
399 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