From: Jérôme Benoit Date: Fri, 21 Jul 2023 13:53:55 +0000 (+0200) Subject: fix: wait for worker exit to clean the worker set X-Git-Tag: v1.2.20~174 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b3ded6aeb2468b6fa4fa7f456da929912626d8ec;p=e-mobility-charging-stations-simulator.git fix: wait for worker exit to clean the worker set Signed-off-by: Jérôme Benoit --- diff --git a/src/worker/WorkerSet.ts b/src/worker/WorkerSet.ts index 2514d723..42109a98 100644 --- a/src/worker/WorkerSet.ts +++ b/src/worker/WorkerSet.ts @@ -77,15 +77,15 @@ export class WorkerSet extends WorkerAbstract { /** @inheritDoc */ public async stop(): Promise { for (const workerSetElement of this.workerSet) { + const worker = workerSetElement.worker; const workerExitPromise = new Promise((resolve) => { - workerSetElement.worker.on('exit', () => { + worker.on('exit', () => { resolve(); }); }); - await workerSetElement.worker.terminate(); + await worker.terminate(); await workerExitPromise; } - this.workerSet.clear(); } /** @inheritDoc */