]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(auth): use Math.floor for TTL computation to avoid serving expired cache entries
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 31 Mar 2026 20:14:39 +0000 (22:14 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 31 Mar 2026 20:14:39 +0000 (22:14 +0200)
src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts

index 483e331ac12fce9766ead0b4b0301f4e0e124c30..f8f7d3d9ec897047cea69b765799cd1848c46b7e 100644 (file)
@@ -563,7 +563,7 @@ export class OCPPAuthServiceImpl implements OCPPAuthService {
     if (expiryDate != null) {
       const expiry = convertToDate(expiryDate)
       if (expiry != null) {
-        const ttlSeconds = Math.ceil((expiry.getTime() - Date.now()) / 1000)
+        const ttlSeconds = Math.floor((expiry.getTime() - Date.now()) / 1000)
         if (ttlSeconds <= 0) {
           logger.debug(
             `${this.chargingStation.logPrefix()} ${moduleName}.updateCacheEntry: Skipping expired entry for ${truncateId(identifier)}`