fix: ensure graceful shutdown waits only for started stations stopping
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 4 Jan 2024 13:42:10 +0000 (14:42 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 4 Jan 2024 13:42:10 +0000 (14:42 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/Bootstrap.ts

index 3993437be907c934cd1e937d39ffe532dd3bab27..22b3207b57e5a03fbe09e3d250d8405486ba22ec 100644 (file)
@@ -223,16 +223,16 @@ export class Bootstrap extends EventEmitter {
   private async waitChargingStationsStopped (): Promise<string> {
     return await new Promise<string>((resolve, reject) => {
       const waitTimeout = setTimeout(() => {
-        const message = `Timeout ${formatDurationMilliSeconds(
+        const timeoutMessage = `Timeout ${formatDurationMilliSeconds(
           Constants.STOP_CHARGING_STATIONS_TIMEOUT
         )} reached at stopping charging stations`
-        console.warn(chalk.yellow(message))
-        reject(new Error(message))
+        console.warn(chalk.yellow(timeoutMessage))
+        reject(new Error(timeoutMessage))
       }, Constants.STOP_CHARGING_STATIONS_TIMEOUT)
       waitChargingStationEvents(
         this,
         ChargingStationWorkerMessageEvents.stopped,
-        this.numberOfChargingStations
+        this.numberOfStartedChargingStations
       )
         .then(() => {
           resolve('Charging stations stopped')