Fix type cast at AsyncResource usage
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 4 Oct 2022 09:43:41 +0000 (11:43 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 4 Oct 2022 09:43:41 +0000 (11:43 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/AutomaticTransactionGenerator.ts
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts

index e32c3c98109f6f520142d1499411b35d12babfcc..a6d3031c88336801233beaba865ab68bf2c5abe6 100644 (file)
@@ -96,10 +96,12 @@ export default class AutomaticTransactionGenerator extends AsyncResource {
         this.internalStartConnector.bind(this) as (
           this: AutomaticTransactionGenerator,
           ...args: any[]
-        ) => void,
+        ) => Promise<void>,
         this,
         connectorId
-      );
+      ).catch(() => {
+        /* This is intentional */
+      });
     } else if (this.connectorsStatus.get(connectorId)?.start === true) {
       logger.warn(`${this.logPrefix(connectorId)} is already started on connector`);
     }
index f7e4489a212a2331b57e7c8cb6385e23b0075af5..1ad01827f1519aef033590f68254323484dc1fab 100644 (file)
@@ -379,14 +379,18 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
     chargingStation: ChargingStation,
     commandPayload: ResetRequest
   ): DefaultResponse {
-    this.asyncResource.runInAsyncScope(
-      chargingStation.reset.bind(chargingStation) as (
-        this: ChargingStation,
-        ...args: any[]
-      ) => void,
-      chargingStation,
-      (commandPayload.type + 'Reset') as OCPP16StopTransactionReason
-    );
+    this.asyncResource
+      .runInAsyncScope(
+        chargingStation.reset.bind(chargingStation) as (
+          this: ChargingStation,
+          ...args: any[]
+        ) => Promise<void>,
+        chargingStation,
+        (commandPayload.type + 'Reset') as OCPP16StopTransactionReason
+      )
+      .catch(() => {
+        /* This is intentional */
+      });
     logger.info(
       `${chargingStation.logPrefix()} ${
         commandPayload.type