CLI: respect loopback gateway probe timeout

This commit is contained in:
ted 2026-03-15 10:41:15 -07:00 committed by Ayaan Zaidi
parent 9fb78453e0
commit b946cc679a
No known key found for this signature in database
3 changed files with 36 additions and 1 deletions

View File

@ -567,6 +567,26 @@ describe("gateway-status command", () => {
expect(targets.some((t) => t.kind === "sshTunnel")).toBe(true);
});
it("passes the full caller timeout through to local loopback probes", async () => {
const { runtime } = createRuntimeCapture();
probeGateway.mockClear();
readBestEffortConfig.mockResolvedValueOnce({
gateway: {
mode: "local",
auth: { mode: "token", token: "ltok" },
},
} as never);
await runGatewayStatus(runtime, { timeout: "15000", json: true });
expect(probeGateway).toHaveBeenCalledWith(
expect.objectContaining({
url: "ws://127.0.0.1:18789",
timeoutMs: 15_000,
}),
);
});
it("skips invalid ssh-auto discovery targets", async () => {
const { runtime } = createRuntimeCapture();
await withEnvAsync({ USER: "steipete" }, async () => {

View File

@ -6,6 +6,7 @@ import {
isScopeLimitedProbeFailure,
renderProbeSummaryLine,
resolveAuthForTarget,
resolveProbeBudgetMs,
} from "./helpers.js";
describe("extractConfigSummary", () => {
@ -273,3 +274,15 @@ describe("probe reachability classification", () => {
expect(renderProbeSummaryLine(probe, false)).toContain("RPC: failed");
});
});
describe("resolveProbeBudgetMs", () => {
it("lets local loopback probes use the full caller budget", () => {
expect(resolveProbeBudgetMs(15_000, "localLoopback")).toBe(15_000);
expect(resolveProbeBudgetMs(3_000, "localLoopback")).toBe(3_000);
});
it("keeps non-local probe caps unchanged", () => {
expect(resolveProbeBudgetMs(15_000, "configRemote")).toBe(1_500);
expect(resolveProbeBudgetMs(15_000, "sshTunnel")).toBe(2_000);
});
});

View File

@ -118,7 +118,9 @@ export function resolveTargets(cfg: OpenClawConfig, explicitUrl?: string): Gatew
export function resolveProbeBudgetMs(overallMs: number, kind: TargetKind): number {
if (kind === "localLoopback") {
return Math.min(800, overallMs);
// Let the local probe use the caller's full budget. Slow local shells/containers can
// exceed the old fixed cap and produce false "unreachable" results.
return overallMs;
}
if (kind === "sshTunnel") {
return Math.min(2000, overallMs);