Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: limit recovery after missing callback to SendData commands #6373

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
});
},
},
);