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

Method terminateSettled

src/extraction/parse-pool.ts:389–400  ·  view source on GitHub ↗

* Terminate a worker, but not while it is still loading grammars: wait for * the load to finish (or the worker to go away), up to `loadSettleMs` * (GRAMMAR_LOAD_SETTLE_MS — see that constant for the crash this avoids).

(w: ParsePoolWorker)

Source from the content-addressed store, hash-verified

387 * (GRAMMAR_LOAD_SETTLE_MS — see that constant for the crash this avoids).
388 */
389 private async terminateSettled(w: ParsePoolWorker): Promise<void> {
390 const load = this.loads.get(w);
391 if (load) {
392 let cap: NodeJS.Timeout | undefined;
393 await Promise.race([
394 load.settled,
395 new Promise<void>((resolve) => { cap = setTimeout(resolve, this.loadSettleMs); cap.unref?.(); }),
396 ]);
397 clearTimeout(cap);
398 }
399 try { await w.terminate(); } catch { /* already gone */ }
400 }
401
402 private removeWorker(w: ParsePoolWorker): void {
403 this.workers.delete(w);

Callers 1

destroyMethod · 0.95

Calls 2

getMethod · 0.65
terminateMethod · 0.65

Tested by

no test coverage detected