]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(ocpp20): clean up VariableManager mappings cache on station stop
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 15 Mar 2026 18:23:00 +0000 (19:23 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 15 Mar 2026 18:23:00 +0000 (19:23 +0100)
invalidateMappingsCache was never called on station stop, leaking
invalidVariables and validatedStations entries for each stopped station.
Call it alongside resetRuntimeOverrides in stop() for complete cleanup.

src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts

index 3e2a783e80264ce8464a3656ac81e8ea65d6825c..50ca5287d26767e0b4e1108c5f87c87392268aac 100644 (file)
@@ -667,11 +667,14 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
       this.stationStates.delete(chargingStation)
     }
     try {
-      OCPP20VariableManager.getInstance().resetRuntimeOverrides(chargingStation.stationInfo?.hashId)
-      logger.debug(`${chargingStation.logPrefix()} ${moduleName}.stop: Runtime overrides cleared`)
+      const variableManager = OCPP20VariableManager.getInstance()
+      const stationId = chargingStation.stationInfo?.hashId
+      variableManager.resetRuntimeOverrides(stationId)
+      variableManager.invalidateMappingsCache(stationId)
+      logger.debug(`${chargingStation.logPrefix()} ${moduleName}.stop: Per-station state cleared`)
     } catch (error) {
       logger.error(
-        `${chargingStation.logPrefix()} ${moduleName}.stop: Error clearing runtime overrides:`,
+        `${chargingStation.logPrefix()} ${moduleName}.stop: Error clearing per-station state:`,
         error
       )
     }