fix: ensure firmware update simulation always run as async resource
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 6 Jun 2023 23:15:57 +0000 (01:15 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 6 Jun 2023 23:15:57 +0000 (01:15 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts

index cdede34b6dc624bfdcf101f8090dd82508540053..21da005239070a634ba3cb9b253c4eb1b8a769cf 100644 (file)
@@ -1085,7 +1085,14 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
       ).catch(Constants.EMPTY_FUNCTION);
     } else {
       setTimeout(() => {
-        this.updateFirmwareSimulation(chargingStation).catch(Constants.EMPTY_FUNCTION);
+        this.runInAsyncScope(
+          this.updateFirmwareSimulation.bind(this) as (
+            this: OCPP16IncomingRequestService,
+            ...args: any[]
+          ) => Promise<void>,
+          this,
+          chargingStation
+        ).catch(Constants.EMPTY_FUNCTION);
       }, retrieveDate?.getTime() - now);
     }
     return OCPP16Constants.OCPP_RESPONSE_EMPTY;