From dfe81c8fd4f72977934e00a2b6d20e04c87ac5c8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 20 Mar 2023 23:40:56 +0100 Subject: [PATCH] fix: fix setInterval deferencing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.ts | 2 ++ src/performance/PerformanceStatistics.ts | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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` -- 2.34.1