fix(nodes): preserve node inventory failures (#126609)

This commit is contained in:
Peter Steinberger
2026-08-20 02:06:09 -07:00
committed by GitHub
parent c55d9b6d20
commit 015913306f
8 changed files with 424 additions and 57 deletions
+34 -3
View File
@@ -1,6 +1,8 @@
// Program nodes basic e2e tests cover node command registration through the full CLI program.
import { Command } from "commander";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { GatewayProtocolRequestTimeoutError } from "../../packages/gateway-client/src/protocol-request.js";
import { GatewayClientRequestError } from "../../packages/gateway-client/src/request-error.js";
import {
createIosNodeListResponse,
formatRuntimeLogCallArg,
@@ -687,9 +689,9 @@ describe("cli program (nodes basics)", () => {
params?: { nodeId?: string };
};
if (opts.method === "node.list") {
throw Object.assign(new Error("unknown method: node.list"), {
name: "GatewayClientRequestError",
gatewayCode: "INVALID_REQUEST",
throw new GatewayClientRequestError({
code: "INVALID_REQUEST",
message: "unknown method: node.list",
});
}
if (opts.method === "node.pair.list") {
@@ -877,4 +879,33 @@ describe("cli program (nodes basics)", () => {
expect(invokeRequest?.clientName).toBe("cli");
expect(invokeRequest?.mode).toBe("cli");
});
it("reports the inventory timeout instead of invoking a stale paired node", async () => {
const timeout = new GatewayProtocolRequestTimeoutError({
method: "node.list",
timeoutMs: 80,
requestSent: true,
});
programGatewayCallMock.mockImplementation(async (...args: unknown[]) => {
const { method } = (args[0] ?? {}) as { method?: string };
if (method === "node.list") {
throw timeout;
}
if (method === "node.pair.list") {
return { pending: [], paired: [{ nodeId: "stale-node", displayName: "Stale Node" }] };
}
throw new GatewayClientRequestError({
code: "UNAVAILABLE",
message: "node not connected",
});
});
await expect(
runProgram(["nodes", "invoke", "--node", "Stale Node", "--command", "canvas.hide"]),
).rejects.toThrow("exit");
expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining(timeout.message));
expect(gatewayRequests().map(({ method }) => method)).toEqual(["node.list"]);
expect(runtime.writeJson).not.toHaveBeenCalled();
});
});