From 0320e2bb72ca522c3932850cce0601ab0a895ad3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 29 May 2024 21:24:52 +0200 Subject: [PATCH] fix: ensure boot notification response is assigned before querying MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- package.json | 4 +- pnpm-lock.yaml | 51 +++++++++++-------- src/charging-station/ChargingStation.ts | 1 + .../ocpp/1.6/OCPP16ResponseService.ts | 1 + .../ocpp/2.0/OCPP20ResponseService.ts | 1 + 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 6bac2523..f591e314 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "http-status-codes": "^2.3.0", "logform": "^2.6.0", "mnemonist": "0.40.0-rc1", - "mongodb": "^6.6.2", + "mongodb": "^6.7.0", "poolifier": "^4.0.13", "rambda": "^9.2.0", "tar": "^7.1.0", @@ -121,7 +121,7 @@ "@commitlint/config-conventional": "^19.2.2", "@mikro-orm/cli": "^6.2.8", "@release-it/bumper": "^6.0.1", - "@types/node": "^20.12.12", + "@types/node": "^20.12.13", "@types/semver": "^7.5.8", "@types/ws": "^8.5.10", "@typescript-eslint/eslint-plugin": "^7.11.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2931e03d..95dfe46f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -54,8 +54,8 @@ importers: specifier: 0.40.0-rc1 version: 0.40.0-rc1 mongodb: - specifier: ^6.6.2 - version: 6.6.2(socks@2.8.3) + specifier: ^6.7.0 + version: 6.7.0(socks@2.8.3) poolifier: specifier: ^4.0.13 version: 4.0.13 @@ -84,7 +84,7 @@ importers: devDependencies: '@commitlint/cli': specifier: ^19.3.0 - version: 19.3.0(@types/node@20.12.12)(typescript@5.4.5) + version: 19.3.0(@types/node@20.12.13)(typescript@5.4.5) '@commitlint/config-conventional': specifier: ^19.2.2 version: 19.2.2 @@ -95,8 +95,8 @@ importers: specifier: ^6.0.1 version: 6.0.1(release-it@17.3.0(typescript@5.4.5)) '@types/node': - specifier: ^20.12.12 - version: 20.12.12 + specifier: ^20.12.13 + version: 20.12.13 '@types/semver': specifier: ^7.5.8 version: 7.5.8 @@ -186,7 +186,7 @@ importers: version: 7.6.2 ts-node: specifier: ^10.9.2 - version: 10.9.2(@types/node@20.12.12)(typescript@5.4.5) + version: 10.9.2(@types/node@20.12.13)(typescript@5.4.5) tsx: specifier: ^4.11.0 version: 4.11.0 @@ -1246,6 +1246,9 @@ packages: '@types/node@20.12.12': resolution: {integrity: sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==} + '@types/node@20.12.13': + resolution: {integrity: sha512-gBGeanV41c1L171rR7wjbMiEpEI/l5XFQdLLfhr/REwpgDy/4U8y89+i8kRiLzDyZdOkXh+cRaTetUnCYutoXA==} + '@types/offscreencanvas@2019.3.0': resolution: {integrity: sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q==} @@ -4365,8 +4368,8 @@ packages: mongodb-connection-string-url@3.0.1: resolution: {integrity: sha512-XqMGwRX0Lgn05TDB4PyG2h2kKO/FfWJyCzYQbIhXUxz7ETt0I/FqHjUeqj37irJ+Dl1ZtU82uYyj14u2XsZKfg==} - mongodb@6.6.2: - resolution: {integrity: sha512-ZF9Ugo2JCG/GfR7DEb4ypfyJJyiKbg5qBYKRintebj8+DNS33CyGMkWbrS9lara+u+h+yEOGSRiLhFO/g1s1aw==} + mongodb@6.7.0: + resolution: {integrity: sha512-TMKyHdtMcO0fYBNORiYdmM25ijsHs+Njs963r4Tro4OQZzqYigAzYQouwWRg4OIaiLRUEGUh/1UAcH5lxdSLIA==} engines: {node: '>=16.20.1'} peerDependencies: '@aws-sdk/credential-providers': ^3.188.0 @@ -6637,11 +6640,11 @@ snapshots: '@colors/colors@1.6.0': {} - '@commitlint/cli@19.3.0(@types/node@20.12.12)(typescript@5.4.5)': + '@commitlint/cli@19.3.0(@types/node@20.12.13)(typescript@5.4.5)': dependencies: '@commitlint/format': 19.3.0 '@commitlint/lint': 19.2.2 - '@commitlint/load': 19.2.0(@types/node@20.12.12)(typescript@5.4.5) + '@commitlint/load': 19.2.0(@types/node@20.12.13)(typescript@5.4.5) '@commitlint/read': 19.2.1 '@commitlint/types': 19.0.3 execa: 8.0.1 @@ -6688,7 +6691,7 @@ snapshots: '@commitlint/rules': 19.0.3 '@commitlint/types': 19.0.3 - '@commitlint/load@19.2.0(@types/node@20.12.12)(typescript@5.4.5)': + '@commitlint/load@19.2.0(@types/node@20.12.13)(typescript@5.4.5)': dependencies: '@commitlint/config-validator': 19.0.3 '@commitlint/execute-rule': 19.0.0 @@ -6696,7 +6699,7 @@ snapshots: '@commitlint/types': 19.0.3 chalk: 5.3.0 cosmiconfig: 9.0.0(typescript@5.4.5) - cosmiconfig-typescript-loader: 5.0.0(@types/node@20.12.12)(cosmiconfig@9.0.0(typescript@5.4.5))(typescript@5.4.5) + cosmiconfig-typescript-loader: 5.0.0(@types/node@20.12.13)(cosmiconfig@9.0.0(typescript@5.4.5))(typescript@5.4.5) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -6981,7 +6984,7 @@ snapshots: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 20.12.12 + '@types/node': 20.12.13 '@types/yargs': 17.0.32 chalk: 4.1.2 @@ -7331,7 +7334,7 @@ snapshots: '@types/conventional-commits-parser@5.0.0': dependencies: - '@types/node': 20.12.12 + '@types/node': 20.12.13 '@types/eslint@8.56.10': dependencies: @@ -7370,6 +7373,10 @@ snapshots: dependencies: undici-types: 5.26.5 + '@types/node@20.12.13': + dependencies: + undici-types: 5.26.5 + '@types/offscreencanvas@2019.3.0': {} '@types/seedrandom@2.4.34': {} @@ -7392,7 +7399,7 @@ snapshots: '@types/ws@8.5.10': dependencies: - '@types/node': 20.12.12 + '@types/node': 20.12.13 '@types/yargs-parser@21.0.3': {} @@ -8555,9 +8562,9 @@ snapshots: core-util-is@1.0.3: {} - cosmiconfig-typescript-loader@5.0.0(@types/node@20.12.12)(cosmiconfig@9.0.0(typescript@5.4.5))(typescript@5.4.5): + cosmiconfig-typescript-loader@5.0.0(@types/node@20.12.13)(cosmiconfig@9.0.0(typescript@5.4.5))(typescript@5.4.5): dependencies: - '@types/node': 20.12.12 + '@types/node': 20.12.13 cosmiconfig: 9.0.0(typescript@5.4.5) jiti: 1.21.0 typescript: 5.4.5 @@ -10492,7 +10499,7 @@ snapshots: jest-util@29.7.0: dependencies: '@jest/types': 29.6.3 - '@types/node': 20.12.12 + '@types/node': 20.12.13 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -10851,7 +10858,7 @@ snapshots: mariadb@3.3.0: dependencies: '@types/geojson': 7946.0.14 - '@types/node': 20.12.12 + '@types/node': 20.12.13 denque: 2.1.0 iconv-lite: 0.6.3 lru-cache: 10.2.2 @@ -11060,7 +11067,7 @@ snapshots: '@types/whatwg-url': 11.0.5 whatwg-url: 13.0.0 - mongodb@6.6.2(socks@2.8.3): + mongodb@6.7.0(socks@2.8.3): dependencies: '@mongodb-js/saslprep': 1.1.7 bson: 6.7.0 @@ -12605,14 +12612,14 @@ snapshots: '@ts-morph/common': 0.23.0 code-block-writer: 13.0.1 - ts-node@10.9.2(@types/node@20.12.12)(typescript@5.4.5): + ts-node@10.9.2(@types/node@20.12.13)(typescript@5.4.5): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.11 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 20.12.12 + '@types/node': 20.12.13 acorn: 8.11.3 acorn-walk: 8.3.2 arg: 4.1.3 diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index ba197954..7cfb70f2 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1832,6 +1832,7 @@ export class ChargingStation extends EventEmitter { if (!this.isRegistered()) { // Send BootNotification do { + // FIXME: duplicated assignment with the boot notification response handler this.bootNotificationResponse = await this.ocppRequestService.requestHandler< BootNotificationRequest, BootNotificationResponse diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index ff04f4dc..46c6d401 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -528,6 +528,7 @@ export class OCPP16ResponseService extends OCPPResponseService { OCPP16ServiceUtils.startHeartbeatInterval(chargingStation, payload.interval) } if (Object.values(RegistrationStatusEnumType).includes(payload.status)) { + chargingStation.bootNotificationResponse = payload if (chargingStation.isRegistered()) { chargingStation.emit(ChargingStationEvents.registered) if (chargingStation.inAcceptedState()) { diff --git a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts index 54ccdeec..1eac7a88 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts @@ -194,6 +194,7 @@ export class OCPP20ResponseService extends OCPPResponseService { OCPP20ServiceUtils.startHeartbeatInterval(chargingStation, payload.interval) } if (Object.values(RegistrationStatusEnumType).includes(payload.status)) { + chargingStation.bootNotificationResponse = payload if (chargingStation.isRegistered()) { chargingStation.emit(ChargingStationEvents.registered) if (chargingStation.inAcceptedState()) { -- 2.34.1