A worker died (crash hook / OOM exit / spawn error). Reject its in-flight * parse so the caller's retry pass can re-attempt it, then respawn.
(w: ParsePoolWorker, message: string)
| 311 | /** A worker died (crash hook / OOM exit / spawn error). Reject its in-flight |
| 312 | * parse so the caller's retry pass can re-attempt it, then respawn. */ |
| 313 | private onWorkerGone(w: ParsePoolWorker, message: string): void { |
| 314 | if (!this.workers.has(w)) return; // already handled (error+exit both fire), or recycled |
| 315 | this.removeWorker(w); |
| 316 | this.totalCrashes++; |
| 317 | const job = this.inflight.get(w); |
| 318 | this.inflight.delete(w); |
| 319 | try { void w.terminate(); } catch { /* already gone */ } |
| 320 | if (job) this.settle(job, undefined, new Error(message)); |
| 321 | if (this.healthy) this.spawnOne(); // keep capacity |
| 322 | this.drain(); |
| 323 | } |
| 324 | |
| 325 | /** Tear down a worker that has hit its recycle threshold and replace it. Not a |
| 326 | * crash, so it doesn't count against the budget. */ |