Skip to content

Commit c337919

Browse files
authored
fix: clarify cloud dispatch and heartbeat timeout diagnostics (#128434)
* fix: clarify cloud dispatch and heartbeat timeout diagnostics * test(crabbox): satisfy heartbeat timeout regression lint
1 parent 9284e23 commit c337919

4 files changed

Lines changed: 38 additions & 3 deletions

File tree

‎extensions/crabbox/src/crabbox-worker-heartbeat.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export function createCrabboxHeartbeatManager(dependencies: {
6262
const controller = new AbortController();
6363
entry.controller = controller;
6464
let result: SpawnResult;
65+
const startedAt = Date.now();
6566
try {
6667
result = await dependencies.run(entry, controller.signal);
6768
} catch (error) {
@@ -93,7 +94,8 @@ export function createCrabboxHeartbeatManager(dependencies: {
9394
}
9495
if (!entry.failureWarned) {
9596
entry.failureWarned = true;
96-
warn(entry, crabboxCommandError("heartbeat", result).message);
97+
const message = crabboxCommandError("heartbeat", result).message;
98+
warn(entry, message.replace("(timeout)", `(timeout after ${Date.now() - startedAt} ms)`));
9799
}
98100
schedule(entry);
99101
};

‎extensions/crabbox/src/crabbox-worker-provider.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,6 +2097,39 @@ describe("Crabbox worker provider", () => {
20972097
}
20982098
});
20992099

2100+
it("reports the measured heartbeat duration when the command times out", async () => {
2101+
vi.useFakeTimers();
2102+
const warnings: string[] = [];
2103+
const provider = providerWithRunner(
2104+
async (argv) => {
2105+
if (argv[1] === "inspect") {
2106+
return commandResult({ stdout: inspectJson() });
2107+
}
2108+
if (argv[1] === "heartbeat") {
2109+
await new Promise<void>((resolve) => {
2110+
setTimeout(resolve, 60_012);
2111+
});
2112+
return commandResult({ code: null, killed: true, termination: "timeout" });
2113+
}
2114+
return commandResult();
2115+
},
2116+
(message) => warnings.push(message),
2117+
);
2118+
const lease = lifecycleLease();
2119+
2120+
try {
2121+
await expect(provider.inspect(lease)).resolves.toStrictEqual({ status: "active" });
2122+
await vi.advanceTimersByTimeAsync(60_012);
2123+
2124+
expect(warnings).toEqual([
2125+
"Crabbox heartbeat did not exit normally (timeout after 60012 ms); cloud worker machines may be reaped after 60m of coordinator-idle time",
2126+
]);
2127+
} finally {
2128+
await provider.destroy(lease);
2129+
vi.useRealTimers();
2130+
}
2131+
});
2132+
21002133
it("keeps heartbeat transport failures out of lifecycle operations and retries", async () => {
21012134
vi.useFakeTimers();
21022135
let heartbeatAttempts = 0;

‎src/gateway/server-methods/sessions-dispatch.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ async function validateDispatchExecutionMode(params: {
171171
}
172172
respondInvalidWorkerSession(
173173
params.respond,
174-
`runtime ${params.sessionRuntime} requires an SSH-backed cloud worker provider; choose a provider that supports remote-exec, or select an agent/model route with agentRuntime.id "openclaw"`,
174+
`selected cloud worker provider does not support the remote-exec execution mode required by runtime ${params.sessionRuntime}; use an approved paired device or a provider that advertises remote-exec`,
175175
);
176176
return false;
177177
}

‎src/gateway/server-methods/sessions.dispatch.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ describe("sessions.dispatch", () => {
437437
expect.objectContaining({
438438
code: ErrorCodes.INVALID_REQUEST,
439439
message:
440-
'runtime codex requires an SSH-backed cloud worker provider; choose a provider that supports remote-exec, or select an agent/model route with agentRuntime.id "openclaw"',
440+
"selected cloud worker provider does not support the remote-exec execution mode required by runtime codex; use an approved paired device or a provider that advertises remote-exec",
441441
}),
442442
);
443443
});

0 commit comments

Comments
 (0)