]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(tests): cleanup ALL private intervals in cleanupChargingStation
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 1 Mar 2026 00:07:09 +0000 (01:07 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 1 Mar 2026 00:07:09 +0000 (01:07 +0100)
Adds cleanup for:
- wsPingSetInterval (private) - WebSocket ping timer
- flushMessageBufferSetInterval (private) - message buffer flush timer
- transactionTxUpdatedSetInterval - OCPP 2.0 transaction update timer

These uncleaned intervals were keeping the Node.js event loop alive,
causing Windows CI tests to hang indefinitely.

tests/charging-station/helpers/StationHelpers.ts

index d88939cb326af3a3d6bdbdc928e13865f79b753f..230fd8dce3122c8020cb00a7acde0d05d82266ea 100644 (file)
@@ -175,12 +175,23 @@ export function cleanupChargingStation (station: ChargingStation): void {
     station.heartbeatSetInterval = undefined
   }
 
-  // Stop WebSocket ping timer
-  if (station.wsPingSetInterval != null) {
-    clearInterval(station.wsPingSetInterval)
-    station.wsPingSetInterval = undefined
+  // Stop WebSocket ping timer (private, accessed for cleanup)
+  /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access,
+     @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument */
+  const stationInternal = station as any
+  if (stationInternal.wsPingSetInterval != null) {
+    clearInterval(stationInternal.wsPingSetInterval)
+    stationInternal.wsPingSetInterval = undefined
   }
 
+  // Stop message buffer flush timer (private, accessed for cleanup)
+  if (stationInternal.flushMessageBufferSetInterval != null) {
+    clearInterval(stationInternal.flushMessageBufferSetInterval)
+    stationInternal.flushMessageBufferSetInterval = undefined
+  }
+  /* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access,
+     @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument */
+
   // Close WebSocket connection
   if (station.wsConnection != null) {
     try {
@@ -197,21 +208,29 @@ export function cleanupChargingStation (station: ChargingStation): void {
     // Ignore errors during cleanup
   }
 
-  // Clear connector transaction state
+  // Clear connector transaction state and timers
   for (const connectorStatus of station.connectors.values()) {
     if (connectorStatus.transactionSetInterval != null) {
       clearInterval(connectorStatus.transactionSetInterval)
       connectorStatus.transactionSetInterval = undefined
     }
+    if (connectorStatus.transactionTxUpdatedSetInterval != null) {
+      clearInterval(connectorStatus.transactionTxUpdatedSetInterval)
+      delete connectorStatus.transactionTxUpdatedSetInterval
+    }
   }
 
-  // Clear EVSE connector transaction state
+  // Clear EVSE connector transaction state and timers
   for (const evseStatus of station.evses.values()) {
     for (const connectorStatus of evseStatus.connectors.values()) {
       if (connectorStatus.transactionSetInterval != null) {
         clearInterval(connectorStatus.transactionSetInterval)
         connectorStatus.transactionSetInterval = undefined
       }
+      if (connectorStatus.transactionTxUpdatedSetInterval != null) {
+        clearInterval(connectorStatus.transactionTxUpdatedSetInterval)
+        delete connectorStatus.transactionTxUpdatedSetInterval
+      }
     }
   }