From a42e0024999e5998072d543a0b427ec2580cc6a5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 20 Sep 2022 11:29:09 +0200 Subject: [PATCH] Only delete the request directly from the cache when needed at response handling error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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); } } } -- 2.34.1