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)
| 413 | /** A worker died (crash hook / OOM exit / spawn error). Reject its in-flight |
| 414 | * parse so the caller's retry pass can re-attempt it, then respawn. */ |
| 415 | private onWorkerGone(w: ParsePoolWorker, message: string): void { |
| 416 | if (!this.workers.has(w)) return; // already handled (error+exit both fire), or recycled |
| 417 | this.removeWorker(w); |
| 418 | this.totalCrashes++; |
| 419 | const job = this.inflight.get(w); |
| 420 | this.inflight.delete(w); |
| 421 | try { void w.terminate(); } catch { /* already gone */ } |
| 422 | if (job) this.settle(job, undefined, new Error(message)); |
| 423 | if (this.healthy) this.spawnOne(); // keep capacity |
| 424 | this.drain(); |
| 425 | } |
| 426 | |
| 427 | /** Tear down a worker that has hit its recycle threshold and replace it. Not a |
| 428 | * crash, so it doesn't count against the budget. */ |