()
| 201 | private everReady = false; |
| 202 | |
| 203 | private spawnOne(): void { |
| 204 | if (this.destroyed || this.workers.size >= this.maxSize) return; |
| 205 | let w: PoolWorker; |
| 206 | try { |
| 207 | w = this.createWorker(); |
| 208 | } catch { |
| 209 | this.totalCrashes++; // counts toward the circuit breaker |
| 210 | return; |
| 211 | } |
| 212 | this.workers.add(w); |
| 213 | this.pendingWorkers.add(w); |
| 214 | w.on('message', (m) => this.onMessage(w, (m ?? {}) as WorkerMessage)); |
| 215 | w.on('error', () => this.onWorkerGone(w)); |
| 216 | w.on('exit', (code) => { if (code !== 0) this.onWorkerGone(w); }); |
| 217 | } |
| 218 | |
| 219 | private onMessage(w: PoolWorker, m: WorkerMessage): void { |
| 220 | if (!m) return; |
no test coverage detected