fix: ensure event listeners are always removed at simulator stop
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 29 Nov 2023 14:27:19 +0000 (15:27 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 29 Nov 2023 14:27:19 +0000 (15:27 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
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)