From: Jérôme Benoit Date: Mon, 20 Nov 2023 14:50:12 +0000 (+0100) Subject: fix: do not log twice OCPP request sending error X-Git-Tag: v1.2.26~26 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3febbc9f6498f7f5a6dc754a5fa687d112cc2c9b;p=e-mobility-charging-stations-simulator.git fix: do not log twice OCPP request sending error Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index c24742d7..77e87f43 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -374,13 +374,12 @@ export abstract class OCPPRequestService { reject(ocppError); }; - const rejectWithOcppError = (ocppError: OCPPError): void => { - // Reject response - if (messageType !== MessageType.CALL_MESSAGE) { - return reject(ocppError); + const rejectAndCleanRequestsCache = (ocppError: OCPPError): void => { + // Remove request from the cache + if (messageType === MessageType.CALL_MESSAGE) { + chargingStation.requests.delete(messageId); } - // Reject and remove request from the cache - return errorCallback(ocppError, false); + return reject(ocppError); }; const handleSendError = (ocppError: OCPPError): void => { @@ -400,7 +399,7 @@ export abstract class OCPPRequestService { // Reject and keep request in the cache return reject(ocppError); } - return rejectWithOcppError(ocppError); + return rejectAndCleanRequestsCache(ocppError); }; if (chargingStation.stationInfo?.enableStatistics === true) { @@ -417,7 +416,7 @@ export abstract class OCPPRequestService { if (chargingStation.isWebSocketConnectionOpened() === true) { const beginId = PerformanceStatistics.beginMeasure(commandName); const sendTimeout = setTimeout(() => { - return rejectWithOcppError( + return rejectAndCleanRequestsCache( new OCPPError( ErrorType.GENERIC_ERROR, `Timeout for message id '${messageId}'`,