MCPcopy
hub / github.com/colbymchenry/codegraph / spawnOne

Method spawnOne

src/mcp/query-pool.ts:186–200  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

184 }
185
186 private spawnOne(): void {
187 if (this.destroyed || this.workers.size >= this.maxSize) return;
188 let w: PoolWorker;
189 try {
190 w = this.createWorker();
191 } catch {
192 this.totalCrashes++; // counts toward the circuit breaker
193 return;
194 }
195 this.workers.add(w);
196 this.pendingWorkers.add(w);
197 w.on('message', (m) => this.onMessage(w, (m ?? {}) as WorkerMessage));
198 w.on('error', () => this.onWorkerGone(w));
199 w.on('exit', (code) => { if (code !== 0) this.onWorkerGone(w); });
200 }
201
202 private onMessage(w: PoolWorker, m: WorkerMessage): void {
203 if (!m) return;

Callers 3

constructorMethod · 0.95
onWorkerGoneMethod · 0.95
drainMethod · 0.95

Calls 3

onMessageMethod · 0.95
onWorkerGoneMethod · 0.95
onMethod · 0.65

Tested by

no test coverage detected