Skip to content

Commit

Permalink
fix: limit recovery after missing callback to SendData commands (#6373
Browse files Browse the repository at this point in the history
)
  • Loading branch information
AlCalzone authored Oct 5, 2023
1 parent 9d4316e commit 6861ff8
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/zwave-js/src/lib/driver/Driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5565,7 +5565,9 @@ ${handlers.length} left`,
if (this.isMissingNodeACK(transaction, error)) {
if (this.handleMissingNodeACK(transaction as any, error)) return;
} else if (
isMissingControllerACK(error) || isMissingControllerCallback(error)
isMissingControllerACK(error)
|| (isSendData(transaction.message)
&& isMissingControllerCallback(error))
) {
if (this.handleUnresponsiveController(transaction, error)) return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import {
import { ZWaveErrorCodes, assertZWaveError } from "@zwave-js/core";
import Sinon from "sinon";
import { SoftResetRequest } from "../../serialapi/misc/SoftResetRequest";
import {
RequestNodeInfoRequest,
RequestNodeInfoResponse,
} from "../../serialapi/network-mgmt/RequestNodeInfoMessages";
import {
SendDataAbort,
SendDataRequest,
Expand Down Expand Up @@ -318,3 +322,44 @@ integrationTest(
},
},
);

integrationTest(
"Missing callback recovery only kicks in for SendData commands",
{
// debug: true,

additionalDriverOptions: {
testingHooks: {
skipNodeInterview: true,
},
},

customSetup: async (driver, mockController, mockNode) => {
// This is almost a 1:1 copy of the default behavior, except that the callback never gets sent
const handleBrokenRequestNodeInfo: MockControllerBehavior = {
async onHostMessage(host, controller, msg) {
if (msg instanceof RequestNodeInfoRequest) {
// Notify the host that the message was sent
const res = new RequestNodeInfoResponse(host, {
wasSent: true,
});
await controller.sendToHost(res.serialize());

// And never send a callback
return true;
}
},
};
mockController.defineBehavior(handleBrokenRequestNodeInfo);
},
testBody: async (t, driver, node, mockController, mockNode) => {
// Circumvent the options validation so the test doesn't take forever
driver.options.timeouts.sendDataCallback = 1500;

await assertZWaveError(t, () => node.requestNodeInfo(), {
errorCode: ZWaveErrorCodes.Controller_Timeout,
context: "callback",
});
},
},
);

0 comments on commit 6861ff8

Please sign in to comment.