From 37629fa0934b654d81b6c0e74ce6709dc0b61532 Mon Sep 17 00:00:00 2001 From: AlCalzone Date: Tue, 8 Oct 2024 13:55:53 +0200 Subject: [PATCH] fix: remove all tasks when hard-resetting or entering bootloader (#7255) --- packages/zwave-js/src/lib/driver/Driver.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/zwave-js/src/lib/driver/Driver.ts b/packages/zwave-js/src/lib/driver/Driver.ts index 202132d2adbd..82b2bb77b12d 100644 --- a/packages/zwave-js/src/lib/driver/Driver.ts +++ b/packages/zwave-js/src/lib/driver/Driver.ts @@ -3150,6 +3150,15 @@ export class Driver extends TypedEventEmitter cacheKeys.controller.privateKey, ); + // Drop all scheduled tasks - they don't make sense after a hard reset + await this.scheduler.removeTasks( + () => true, + new ZWaveError( + "The controller is being hard-reset", + ZWaveErrorCodes.Driver_TaskRemoved, + ), + ); + // Update the controller NIF prior to hard resetting await this.controller.setControllerNIF(); await this.controller.hardReset(); @@ -7066,6 +7075,14 @@ ${handlers.length} left`, try { // await this.controller.toggleRF(false); // Avoid re-transmissions etc. communicating with the bootloader + await this.scheduler.removeTasks( + () => true, + new ZWaveError( + "The controller is entering bootloader mode.", + ZWaveErrorCodes.Driver_TaskRemoved, + ), + ); + this.rejectTransactions( (_t) => true, "The controller is entering bootloader mode.",