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)
| 388 | /** A worker died (crash hook / OOM exit / spawn error). Reject its in-flight |
| 389 | * parse so the caller's retry pass can re-attempt it, then respawn. */ |
| 390 | private onWorkerGone(w: ParsePoolWorker, message: string): void { |
| 391 | if (!this.workers.has(w)) return; // already handled (error+exit both fire), or recycled |
| 392 | this.removeWorker(w); |
| 393 | this.totalCrashes++; |
| 394 | const job = this.inflight.get(w); |
| 395 | this.inflight.delete(w); |
| 396 | try { void w.terminate(); } catch { /* already gone */ } |
| 397 | if (job) this.settle(job, undefined, new Error(message)); |
| 398 | if (this.healthy) this.spawnOne(); // keep capacity |
| 399 | this.drain(); |
| 400 | } |
| 401 | |
| 402 | /** Tear down a worker that has hit its recycle threshold and replace it. Not a |
| 403 | * crash, so it doesn't count against the budget. */ |