From: Jérôme Benoit Date: Thu, 4 Jan 2024 13:42:10 +0000 (+0100) Subject: fix: ensure graceful shutdown waits only for started stations stopping X-Git-Tag: v1.2.32~63 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a01134ed215b62a0c82475b9fbb35306fa792bbc;p=e-mobility-charging-stations-simulator.git fix: ensure graceful shutdown waits only for started stations stopping Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 3993437b..22b3207b 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -223,16 +223,16 @@ export class Bootstrap extends EventEmitter { private async waitChargingStationsStopped (): Promise { return await new Promise((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')