Skip to content

Commit

Permalink
fix: race condition causing successful OTW update to be considered ti…
Browse files Browse the repository at this point in the history
…med out (#6912)
  • Loading branch information
AlCalzone authored Jun 10, 2024
1 parent 4f183e7 commit 170d51b
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions packages/zwave-js/src/lib/controller/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7935,16 +7935,23 @@ ${associatedNodes.join(", ")}`,
// We're done, send EOT and wait for the menu screen
await this.driver.bootloader.finishUpload();
try {
await this.driver.waitForBootloaderChunk(
(c) =>
c.type === BootloaderChunkType.Message
&& c.message.includes("upload complete"),
1000,
);
await this.driver.waitForBootloaderChunk(
(c) => c.type === BootloaderChunkType.Menu,
1000,
);
// The bootloader sends the confirmation and the menu screen very quickly.
// Waiting for them separately can cause us to miss the menu screen and
// incorrectly assume the update timed out.

await Promise.all([
this.driver.waitForBootloaderChunk(
(c) =>
c.type === BootloaderChunkType.Message
&& c.message.includes("upload complete"),
1000,
),

this.driver.waitForBootloaderChunk(
(c) => c.type === BootloaderChunkType.Menu,
1000,
),
]);
} catch (e) {
this.driver.controllerLog.print(
"OTW update failed: The bootloader did not acknowledge the end of transfer.",
Expand Down

0 comments on commit 170d51b

Please sign in to comment.