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)
| 235 | /** A worker died (crash hook / OOM exit / spawn error). Reject its in-flight |
| 236 | * parse so the caller's retry pass can re-attempt it, then respawn. */ |
| 237 | private onWorkerGone(w: ParsePoolWorker, message: string): void { |
| 238 | if (!this.workers.has(w)) return; // already handled (error+exit both fire), or recycled |
| 239 | this.removeWorker(w); |
| 240 | this.totalCrashes++; |
| 241 | const job = this.inflight.get(w); |
| 242 | this.inflight.delete(w); |
| 243 | try { void w.terminate(); } catch { /* already gone */ } |
| 244 | if (job) this.settle(job, undefined, new Error(message)); |
| 245 | if (this.healthy) this.spawnOne(); // keep capacity |
| 246 | this.drain(); |
| 247 | } |
| 248 | |
| 249 | /** Tear down a worker that has hit its recycle threshold and replace it. Not a |
| 250 | * crash, so it doesn't count against the budget. */ |