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)
| 330 | /** A worker died (crash hook / OOM exit / spawn error). Reject its in-flight |
| 331 | * parse so the caller's retry pass can re-attempt it, then respawn. */ |
| 332 | private onWorkerGone(w: ParsePoolWorker, message: string): void { |
| 333 | if (!this.workers.has(w)) return; // already handled (error+exit both fire), or recycled |
| 334 | this.removeWorker(w); |
| 335 | this.totalCrashes++; |
| 336 | const job = this.inflight.get(w); |
| 337 | this.inflight.delete(w); |
| 338 | try { void w.terminate(); } catch { /* already gone */ } |
| 339 | if (job) this.settle(job, undefined, new Error(message)); |
| 340 | if (this.healthy) this.spawnOne(); // keep capacity |
| 341 | this.drain(); |
| 342 | } |
| 343 | |
| 344 | /** Tear down a worker that has hit its recycle threshold and replace it. Not a |
| 345 | * crash, so it doesn't count against the budget. */ |