From 64818750b8394051b2a77ccf27ea4c2ff2b7af6e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 4 Oct 2022 11:43:41 +0200 Subject: [PATCH] Fix type cast at AsyncResource usage MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../AutomaticTransactionGenerator.ts | 6 ++++-- .../ocpp/1.6/OCPP16IncomingRequestService.ts | 20 +++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/charging-station/AutomaticTransactionGenerator.ts b/src/charging-station/AutomaticTransactionGenerator.ts index e32c3c98..a6d3031c 100644 --- a/src/charging-station/AutomaticTransactionGenerator.ts +++ b/src/charging-station/AutomaticTransactionGenerator.ts @@ -96,10 +96,12 @@ export default class AutomaticTransactionGenerator extends AsyncResource { this.internalStartConnector.bind(this) as ( this: AutomaticTransactionGenerator, ...args: any[] - ) => void, + ) => Promise, this, connectorId - ); + ).catch(() => { + /* This is intentional */ + }); } else if (this.connectorsStatus.get(connectorId)?.start === true) { logger.warn(`${this.logPrefix(connectorId)} is already started on connector`); } diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index f7e4489a..1ad01827 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -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, + chargingStation, + (commandPayload.type + 'Reset') as OCPP16StopTransactionReason + ) + .catch(() => { + /* This is intentional */ + }); logger.info( `${chargingStation.logPrefix()} ${ commandPayload.type -- 2.34.1