From: Jérôme Benoit Date: Tue, 20 Sep 2022 09:29:09 +0000 (+0200) Subject: Only delete the request directly from the cache when needed at response X-Git-Tag: v1.1.74~28 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a42e0024999e5998072d543a0b427ec2580cc6a5;p=e-mobility-charging-stations-simulator.git Only delete the request directly from the cache when needed at response handling error Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 93042f20..da71a819 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1575,11 +1575,12 @@ export default class ChargingStation { [MessageType.CALL_RESULT_MESSAGE, MessageType.CALL_ERROR_MESSAGE].includes(messageType) === true ) { - // Always remove the request from the cache in case of error at response handling - this.requests.delete(messageId); - // Always reject the deferred promise in case of error at response handling (rejecting an already fulfilled promise is a no-op) if (errorCallback) { + // Reject the deferred promise in case of error at response handling (rejecting an already fulfilled promise is a no-op) errorCallback(error as OCPPError, false); + } else { + // Remove the request from the cache in case of error at response handling + this.requests.delete(messageId); } } }