fix: ensure event listeners are always removed at simulator stop
[e-mobility-charging-stations-simulator.git] / src / charging-station / Bootstrap.ts
index 9fc4f19fdb8d3f45fb3aaab83803d21e527be2f8..6620764559974d12e6ca8a89cf7ccae497937e22 100644 (file)
@@ -194,6 +194,7 @@ export class Bootstrap extends EventEmitter {
         }
         await this.workerImplementation?.stop();
         delete this.workerImplementation;
+        this.removeAllListeners();
         this.uiServer?.stop();
         await this.storage?.close();
         delete this.storage;
@@ -229,7 +230,6 @@ export class Bootstrap extends EventEmitter {
         this.numberOfChargingStations,
       )
         .then(() => {
-          this.removeAllListeners();
           resolve('Charging stations stopped');
         })
         .catch(reject)