Tear down a worker that has hit its recycle threshold and replace it. Not a * crash, so it doesn't count against the budget.
(w: ParsePoolWorker)
| 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. */ |
| 346 | private recycle(w: ParsePoolWorker): void { |
| 347 | this.log(`Recycling worker after ${this.parseCounts.get(w)} parses (heap: ${Math.round(process.memoryUsage().rss / 1024 / 1024)}MB RSS)`); |
| 348 | this.removeWorker(w); |
| 349 | // Fire-and-forget: worker.terminate() can hang if WASM is wedged. |
| 350 | try { void w.terminate(); } catch { /* already gone */ } |
| 351 | if (this.healthy && !this.destroyed) this.spawnOne(); |
| 352 | } |
| 353 | |
| 354 | private removeWorker(w: ParsePoolWorker): void { |
| 355 | this.workers.delete(w); |
no test coverage detected