Fix error handling at OCPP message sending
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / UIHttpServer.ts
index 822244f96081305ef939ae7f107d67f9c840c1a4..37c579dc56a552dc26dbd57ae515378820e9e2d9 100644 (file)
@@ -47,7 +47,6 @@ export default class UIHttpServer extends AbstractUIServer {
             'Content-Type': 'application/json',
           })
           .end(JSON.stringify(payload));
-        this.responseHandlers.delete(uuid);
       } else {
         logger.error(
           `${this.logPrefix(moduleName, 'sendResponse')} Response for unknown request id: ${uuid}`
@@ -58,6 +57,8 @@ export default class UIHttpServer extends AbstractUIServer {
         `${this.logPrefix(moduleName, 'sendResponse')} Error at sending response id '${uuid}':`,
         error
       );
+    } finally {
+      this.responseHandlers.delete(uuid);
     }
   }