fix: fix nullish exception on boot notification handling
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 14 Jan 2024 11:32:08 +0000 (12:32 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 14 Jan 2024 11:32:08 +0000 (12:32 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index 7534f66e72f38abd778d11397b42708a03ab0af3..79d2c7537b7c415dd98223edf39b7204860ad144 100644 (file)
@@ -1761,11 +1761,13 @@ export class ChargingStation extends EventEmitter {
           >(this, RequestCommand.BOOT_NOTIFICATION, this.bootNotificationRequest, {
             skipBufferingOnError: true
           })
-          // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-          this.bootNotificationResponse.currentTime = convertToDate(
-            // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
-            this.bootNotificationResponse?.currentTime
-          )!
+          // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+          if (this.bootNotificationResponse?.currentTime != null) {
+            // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+            this.bootNotificationResponse.currentTime = convertToDate(
+              this.bootNotificationResponse.currentTime
+            )!
+          }
           if (!this.isRegistered()) {
             this.stationInfo?.registrationMaxRetries !== -1 && ++registrationRetryCount
             await sleep(