From: Jérôme Benoit Date: Mon, 20 Mar 2023 22:40:56 +0000 (+0100) Subject: fix: fix setInterval deferencing X-Git-Tag: v1.2.0-0~39 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=dfe81c8fd4f72977934e00a2b6d20e04c87ac5c8;p=e-mobility-charging-stations-simulator.git fix: fix setInterval deferencing Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index c24383e9..718f5eff 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1940,6 +1940,7 @@ export class ChargingStation { private stopWebSocketPing(): void { if (this.webSocketPingSetInterval) { clearInterval(this.webSocketPingSetInterval); + delete this.webSocketPingSetInterval; } } @@ -1997,6 +1998,7 @@ export class ChargingStation { private stopHeartbeat(): void { if (this.heartbeatSetInterval) { clearInterval(this.heartbeatSetInterval); + delete this.heartbeatSetInterval; } } diff --git a/src/performance/PerformanceStatistics.ts b/src/performance/PerformanceStatistics.ts index 69829ff1..8cf0e1ef 100644 --- a/src/performance/PerformanceStatistics.ts +++ b/src/performance/PerformanceStatistics.ts @@ -127,6 +127,7 @@ export class PerformanceStatistics { public stop(): void { if (this.displayInterval) { clearInterval(this.displayInterval); + delete this.displayInterval; } performance.clearMarks(); performance.clearMeasures(); @@ -158,7 +159,7 @@ export class PerformanceStatistics { } private startLogStatisticsInterval(): void { - if (Configuration.getLogStatisticsInterval() > 0) { + if (Configuration.getLogStatisticsInterval() > 0 && !this.displayInterval) { this.displayInterval = setInterval(() => { this.logStatistics(); }, Configuration.getLogStatisticsInterval() * 1000); @@ -167,6 +168,12 @@ export class PerformanceStatistics { Configuration.getLogStatisticsInterval() )}` ); + } else if (this.displayInterval) { + logger.info( + `${this.logPrefix()} already logged every ${Utils.formatDurationSeconds( + Configuration.getLogStatisticsInterval() + )}` + ); } else { logger.info( `${this.logPrefix()} log interval is set to ${Configuration.getLogStatisticsInterval()?.toString()}. Not logging statistics`