]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
fix(ocpp): cancel deferred OCPP 1.6 firmware setTimeout on stop() (#1984)
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 8 Jul 2026 22:19:05 +0000 (00:19 +0200)
committerGitHub <noreply@github.com>
Wed, 8 Jul 2026 22:19:05 +0000 (00:19 +0200)
commit2e691254ddc64aece42656d031f36b11169a6c7c
tree7fef22c6513ab5de03e2b2da6b1b9837b4214e2a
parent0fff8b2a611829b5f996aae0ebc4d50883eb0632
fix(ocpp): cancel deferred OCPP 1.6 firmware setTimeout on stop() (#1984)

The OCPP 1.6 UPDATE_FIRMWARE event listener schedules
updateFirmwareSimulation via setTimeout(...).unref() when retrieveDate
is in the future. .unref() prevents the timer from blocking process
exit, but the callback still fires after stop(): if the station
restarts, the deferred simulation runs against the new connection and
can emit FirmwareStatusNotification messages the CSMS did not request.

Store the timer handle on OCPP16StationState.deferredFirmwareUpdateTimer
(per-station state introduced by #1963 / PR #1983) and release it via
a shared cancelDeferredFirmwareUpdate helper called from both the
schedule site (to supersede a prior pending schedule) and
resetStationState (invoked by the inherited stop() template before the
base deletes the WeakMap entry). The callback clears the handle before
awaiting updateFirmwareSimulation so resetStationState never targets a
fired timer.

Mirrors the OCPP 2.0.1 pattern
(OCPP20IncomingRequestService.resetStationState cancels
certSigningRetryManager.cancelRetryTimer, commit c0b25553).

Closes #1972
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
tests/charging-station/ocpp/1.6/OCPP16IncomingRequestService-Firmware.test.ts