From 11bab87ee7afef93300cd320786b85f6d00df696 Mon Sep 17 00:00:00 2001 From: Dominic Griesel Date: Mon, 20 Nov 2023 16:19:39 +0100 Subject: [PATCH] fix: re-queue current transaction in correct queue --- packages/zwave-js/src/lib/driver/Driver.ts | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/zwave-js/src/lib/driver/Driver.ts b/packages/zwave-js/src/lib/driver/Driver.ts index d9b14632a5f1..14d7e6405530 100644 --- a/packages/zwave-js/src/lib/driver/Driver.ts +++ b/packages/zwave-js/src/lib/driver/Driver.ts @@ -3614,7 +3614,9 @@ export class Driver extends TypedEventEmitter // Re-queue the transaction, so it can get handled next. // Its message generator may have finished, so reset that too. transaction.reset(); - this.queue.add(transaction.clone()); + this.getQueueForTransaction(transaction).add( + transaction.clone(), + ); this._controller?.setStatus(ControllerStatus.Ready); this._recoveryPhase = ControllerRecoveryPhase.None; @@ -3730,7 +3732,9 @@ export class Driver extends TypedEventEmitter // Re-queue the transaction, so it can get handled next. // Its message generator may have finished, so reset that too. transaction.reset(); - this.queue.add(transaction.clone()); + this.getQueueForTransaction(transaction).add( + transaction.clone(), + ); this._controller?.setStatus(ControllerStatus.Ready); this._recoveryPhase = @@ -5158,6 +5162,17 @@ ${handlers.length} left`, return result; } + private getQueueForTransaction(t: Transaction): TransactionQueue { + if ( + t.priority === MessagePriority.Immediate + || t.priority === MessagePriority.ControllerImmediate + ) { + return this.immediateQueue; + } else { + return this.queue; + } + } + /** * Sends a message to the Z-Wave stick. * @param msg The message to send @@ -5267,14 +5282,7 @@ ${handlers.length} left`, transaction.tag = options.tag; // And queue it - if ( - transaction.priority === MessagePriority.Immediate - || transaction.priority === MessagePriority.ControllerImmediate - ) { - this.immediateQueue.add(transaction); - } else { - this.queue.add(transaction); - } + this.getQueueForTransaction(transaction).add(transaction); transaction.setProgress({ state: TransactionState.Queued }); // If the transaction should expire, start the timeout