Repository navigation
Description
[BUG] OCPP 2.0.1 firmware: stationInfo.firmwareStatus persists after abort or exception in simulateFirmwareUpdateLifecycle
Component
Simulator
Description
Follow-up from PR #1962.
OCPP20IncomingRequestService.simulateFirmwareUpdateLifecycle sets chargingStation.stationInfo.firmwareStatus at every notification transition (Downloading, Downloaded, Installing, …, Installed) via sendFirmwareStatusNotification, but its finally block only clears the per-station WeakMap state (activeFirmwareUpdateAbortController, activeFirmwareUpdateRequestId) via clearActiveFirmwareUpdate. stationInfo.firmwareStatus is never reset on exception or abort — it stays at whatever value the last successful notification set (e.g. Downloading).
hasFirmwareUpdateInProgress at src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts:3205 reads stationInfo.firmwareStatus and treats it as authoritative for the trigger-side "in progress" check. TriggerMessage(FirmwareStatusNotification) at line 573 already cross-checks against activeFirmwareUpdateRequestId (fixed in commit 29a8330f), so the trigger emits Idle when the two sources diverge. The underlying data-model split remains: any future consumer of stationInfo.firmwareStatus that does not cross-check will observe a stale non-terminal value on:
- exception paths (thrown
awaitmid-lifecycle →finallyclears requestId, leavesstationInfo.firmwareStatusat last-emitted value) - abort paths (
stop()orhandleRequestUpdateFirmwaresupersession →AbortController.abort()unwinds the lifecycle → same finally behavior)
See also: OCPP 1.6 has the same data-model split (separate issues for handleRequestGetDiagnostics / handleRequestUpdateFirmware on the 1.6 side).
Steps to reproduce
- Start a station with OCPP 2.0.1.
- Send
UpdateFirmware(requestId=A). Lifecycle emitsDownloading, setsstationInfo.firmwareStatus = 'Downloading', awaits retrieve delay. - During the delay, send
UpdateFirmware(requestId=B). Handler aborts A, resetsactiveFirmwareUpdateRequestId, returnsAcceptedCanceled. - Inspect
chargingStation.stationInfo.firmwareStatus→ still'Downloading'(should beIdleor a terminal state for A).
Expected result
stationInfo.firmwareStatus is reset to a coherent terminal value when simulateFirmwareUpdateLifecycle exits via abort or throw:
- clean supersession (abort-and-replace, terminal notification already emitted upstream) →
Idle - exception mid-download →
DownloadFailed - exception mid-install →
InstallationFailed
Actual result
stationInfo.firmwareStatus retains the last-emitted non-terminal status indefinitely.
Proposed fix
Track the current phase inside simulateFirmwareUpdateLifecycle and, in the finally block, when the lifecycle did not reach Installed, reset stationInfo.firmwareStatus:
- exited during download phase →
DownloadFailed(exception) orIdle(clean abort-and-replace) - exited during install phase →
InstallationFailed(exception) orIdle(clean abort-and-replace)
Per OCPP 2.0.1 L01.FR.24 the terminal *Failed notifications on supersession are optional (MAY), so emitting Idle on clean abort is spec-compliant and simpler.
Requires a phase variable + an abort-source signal in the lifecycle scope.
Version
4.10.1
Node.js version
v24.18.0
System
Darwin 26.5.1 (macOS)
Attachments
- PR refactor: audit backlog cleanup — JSDoc gaps, physics warning, ATG robustness, comment sweep #1962 discussion
- Related commits:
d2e9b8b0(extractresetActiveFirmwareUpdateState),29a8330f(trigger cross-check for L01.FR.20)
Activity
fix(ocpp): reset stationInfo.firmwareStatus on abort/exception in sim…
fix(ocpp): reset stationInfo.firmwareStatus on abort/exception in sim…
fix(ocpp): reset stationInfo.firmwareStatus on abort/exception in sim…
fix(ocpp): reset stationInfo.firmwareStatus on abort/exception in sim…
fix(ocpp): reset stationInfo.firmwareStatus on abort/exception in sim…
fix(ocpp): reset stationInfo.firmwareStatus on abort/exception in sim…
fix(ocpp): reset stationInfo.firmwareStatus on abort/exception in sim…
fix(ocpp): reset stationInfo.firmwareStatus on abort/exception in sim…