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

Method onWorkerGone

src/mcp/query-pool.ts:409–428  ·  view source on GitHub ↗
(w: PoolWorker)

Source from the content-addressed store, hash-verified

407 // retry its in-flight job once; a job that keeps crashing workers fails
408 // gracefully so it can't loop the pool forever.
409 private onWorkerGone(w: PoolWorker): void {
410 if (!this.workers.has(w)) return; // already handled (error+exit both fire)
411 this.workers.delete(w);
412 this.pendingWorkers.delete(w);
413 this.idle = this.idle.filter((x) => x !== w);
414 this.totalCrashes++;
415 const job = this.inflight.get(w);
416 this.inflight.delete(w);
417 try { void w.terminate(); } catch { /* already gone */ }
418 if (this.healthy) this.spawnOne(); // keep capacity
419 if (job) {
420 if (job.retries < this.maxRetries && this.healthy) {
421 job.retries++;
422 this.queue.unshift(job); // head of line — retry promptly
423 } else {
424 this.settle(job, { isError: true, content: [{ type: 'text', text: 'codegraph worker crashed; please retry the call.' }] });
425 }
426 }
427 this.drain();
428 }
429
430 private drain(): void {
431 // Grow toward maxSize while queued work outstrips workers that are idle OR

Callers 2

spawnOneMethod · 0.95
onMessageMethod · 0.95

Calls 7

spawnOneMethod · 0.95
settleMethod · 0.95
drainMethod · 0.95
hasMethod · 0.80
deleteMethod · 0.65
getMethod · 0.65
terminateMethod · 0.65

Tested by

no test coverage detected