CLI: respect loopback gateway probe timeout
This commit is contained in:
parent
9fb78453e0
commit
b946cc679a
@ -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 () => {
|
||||
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user