Skip to content

Commit f86be96

Browse files
Alix-007claude
andcommitted
fix(gateway): keep inactive configured remote probes on the short cap
Active configured remote targets (gateway.mode === remote) need the full caller budget for a healthy remote RPC. An inactive configured remote — local mode with a stale leftover gateway.remote.url — must retain the short remote cap (1500ms) so a dead remote host cannot consume the entire caller timeout before the active local probe runs. Adds a regression test for local mode with a stale remote URL. Co-Authored-By: Claude Opus 4.8 <[email protected]>
1 parent a830ab1 commit f86be96

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎src/commands/gateway-status/helpers.test.ts‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ describe("resolveProbeBudgetMs", () => {
369369
).toBe(2_500);
370370
});
371371

372-
it("lets configured and explicit remote probes use the full caller budget", () => {
372+
it("lets active configured and explicit remote probes use the full caller budget", () => {
373373
expect(
374374
resolveProbeBudgetMs(15_000, {
375375
kind: "configRemote",
@@ -386,6 +386,26 @@ describe("resolveProbeBudgetMs", () => {
386386
).toBe(15_000);
387387
});
388388

389+
it("keeps inactive configured remote probes (local mode with a stale remote URL) on the short cap", () => {
390+
// gateway.mode === "local" but a leftover gateway.remote.url is still present:
391+
// resolveTargets marks the configRemote target active === false. A dead remote
392+
// host must not consume the full caller budget before the active local probe.
393+
expect(
394+
resolveProbeBudgetMs(15_000, {
395+
kind: "configRemote",
396+
active: false,
397+
url: "wss://stale-remote.example/ws",
398+
}),
399+
).toBe(1500);
400+
expect(
401+
resolveProbeBudgetMs(500, {
402+
kind: "configRemote",
403+
active: false,
404+
url: "wss://stale-remote.example/ws",
405+
}),
406+
).toBe(500);
407+
});
408+
389409
it("keeps ssh tunnel probes on the short cap", () => {
390410
expect(
391411
resolveProbeBudgetMs(15_000, {

‎src/commands/gateway-status/helpers.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,17 @@ export function resolveProbeBudgetMs(
133133
overallMs: number,
134134
target: Pick<GatewayStatusTarget, "kind" | "active" | "url">,
135135
): number {
136-
if (target.kind === "configRemote" || target.kind === "explicit") {
136+
if (target.kind === "explicit") {
137137
return overallMs;
138138
}
139+
if (target.kind === "configRemote") {
140+
// Active configured remote targets (gateway.mode === "remote") legitimately
141+
// need the full caller budget for a healthy remote RPC. An *inactive*
142+
// configured remote — e.g. local mode with a stale leftover gateway.remote.url
143+
// — must keep the short remote cap so a dead remote host does not consume the
144+
// entire caller timeout before the active local probe runs.
145+
return target.active ? overallMs : Math.min(1500, overallMs);
146+
}
139147
if (target.kind === "sshTunnel") {
140148
return Math.min(2000, overallMs);
141149
}

0 commit comments

Comments
 (0)