(w: PoolWorker, m: WorkerMessage)
| 200 | } |
| 201 | |
| 202 | private onMessage(w: PoolWorker, m: WorkerMessage): void { |
| 203 | if (!m) return; |
| 204 | if (m.type === 'ready') { |
| 205 | this.pendingWorkers.delete(w); |
| 206 | if (m.ok === false) this.totalCrashes++; // hard open failure |
| 207 | this.idle.push(w); |
| 208 | this.drain(); |
| 209 | return; |
| 210 | } |
| 211 | if (m.type === 'result') { |
| 212 | const job = this.inflight.get(w); |
| 213 | this.inflight.delete(w); |
| 214 | this.idle.push(w); |
| 215 | if (job) this.settle(job, m.result ?? busyGuidance(0)); |
| 216 | this.drain(); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | // A worker died (crash hook, OOM, segfault, exit≠0). Respawn a replacement and |
| 221 | // retry its in-flight job once; a job that keeps crashing workers fails |
no test coverage detected