Skip to content

[BUG] OCPP 2.0.1 firmware: stationInfo.firmwareStatus persists after abort or exception in simulateFirmwareUpdateLifecycle #1969

Description

@jerome-benoit

[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 await mid-lifecycle → finally clears requestId, leaves stationInfo.firmwareStatus at last-emitted value)
  • abort paths (stop() or handleRequestUpdateFirmware supersession → 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

  1. Start a station with OCPP 2.0.1.
  2. Send UpdateFirmware(requestId=A). Lifecycle emits Downloading, sets stationInfo.firmwareStatus = 'Downloading', awaits retrieve delay.
  3. During the delay, send UpdateFirmware(requestId=B). Handler aborts A, resets activeFirmwareUpdateRequestId, returns AcceptedCanceled.
  4. Inspect chargingStation.stationInfo.firmwareStatus → still 'Downloading' (should be Idle or 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) or Idle (clean abort-and-replace)
  • exited during install phase → InstallationFailed (exception) or Idle (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

Activity

  1. added
    bug
    simulator
    triage
    on Jul 6, 2026
  2. added 7 commits that reference this issue on Jul 8, 2026
    f1b521b
    299a3fd
    623b690
    3812e86
    04bbb46
    f06c8c4
    7d9ccf3
  3. added a commit that references this issue on Jul 27, 2026
    4f959e9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsimulatortriage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions