From: Jérôme Benoit Date: Sun, 15 Mar 2026 18:36:48 +0000 (+0100) Subject: fix: clear OCPPAuthServiceFactory cached instance on station delete X-Git-Tag: ocpp-server@v3.1.0~17 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=6956e437a497d70f6283c22b1eb53358e352c1ef;p=e-mobility-charging-stations-simulator.git fix: clear OCPPAuthServiceFactory cached instance on station delete clearInstance was never called, leaking one OCPPAuthService per station in the factory's static instances Map after station stop/delete. --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index ef8014f4..5082770d 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -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 { - await this.stop(reason) + public async reset (reason?: StopTransactionReason, graceful = true): Promise { + 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()