]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix: clear OCPPAuthServiceFactory cached instance on station delete
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 15 Mar 2026 18:36:48 +0000 (19:36 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 15 Mar 2026 18:36:48 +0000 (19:36 +0100)
clearInstance was never called, leaking one OCPPAuthService per station
in the factory's static instances Map after station stop/delete.

src/charging-station/ChargingStation.ts

index ef8014f49bac75dd39cec0954556bcf9e5a4bf89..5082770da46538a1bb90e1fc3c36642a1cce0c17 100644 (file)
@@ -142,6 +142,7 @@ import {
   warnTemplateKeysDeprecation,
 } from './Helpers.js'
 import { IdTagsCache } from './IdTagsCache.js'
+import { OCPPAuthServiceFactory } from './ocpp/auth/services/OCPPAuthServiceFactory.js'
 import {
   buildMeterValue,
   buildTransactionEndMeterValue,
@@ -333,6 +334,7 @@ export class ChargingStation extends EventEmitter {
     }
     AutomaticTransactionGenerator.deleteInstance(this)
     PerformanceStatistics.deleteInstance(this.stationInfo?.hashId)
+    OCPPAuthServiceFactory.clearInstance(this)
     if (this.stationInfo != null) {
       const idTagsFile = getIdTagsFile(this.stationInfo)
       if (idTagsFile != null) {
@@ -862,8 +864,8 @@ export class ChargingStation extends EventEmitter {
     }
   }
 
-  public async reset (reason?: StopTransactionReason): Promise<void> {
-    await this.stop(reason)
+  public async reset (reason?: StopTransactionReason, graceful = true): Promise<void> {
+    await this.stop(reason, graceful ? this.stationInfo?.stopTransactionsOnStopped : false)
     // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
     await sleep(this.stationInfo!.resetTime!)
     this.initialize()