fix: do not use async callback with setInterval()
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 19 Jul 2023 19:25:15 +0000 (21:25 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 19 Jul 2023 19:25:15 +0000 (21:25 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index d130392e6c0257da7a6feea2cb8cb205249bc7bc..0d1534f126cd4274b3507ba37f4ed0c5c9162dbb 100644 (file)
@@ -1025,27 +1025,26 @@ export class ChargingStation {
         and starts on charging station now`,
     );
     if (interval > 0) {
-      // eslint-disable-next-line @typescript-eslint/no-misused-promises
-      this.reservationExpirationSetInterval = setInterval(async (): Promise<void> => {
+      this.reservationExpirationSetInterval = setInterval((): void => {
         const now = new Date();
         if (this.hasEvses) {
           for (const evseStatus of this.evses.values()) {
             for (const connectorStatus of evseStatus.connectors.values()) {
               if (connectorStatus.reservation && connectorStatus.reservation.expiryDate < now) {
-                await this.removeReservation(
+                this.removeReservation(
                   connectorStatus.reservation,
                   ReservationTerminationReason.EXPIRED,
-                );
+                ).catch(Constants.EMPTY_FUNCTION);
               }
             }
           }
         } else {
           for (const connectorStatus of this.connectors.values()) {
             if (connectorStatus.reservation && connectorStatus.reservation.expiryDate < now) {
-              await this.removeReservation(
+              this.removeReservation(
                 connectorStatus.reservation,
                 ReservationTerminationReason.EXPIRED,
-              );
+              ).catch(Constants.EMPTY_FUNCTION);
             }
           }
         }