mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(clawsweeper): address review for gitcrawl-1599-fix-register-abortcontroller-for-agent-rpc-runs-so-chat-abort-wo (2)
This commit is contained in:
@@ -266,16 +266,21 @@ function chatRunWatchdogResultIsTerminal(
|
||||
result: ChatRunWatchdogWaitResult | null | undefined,
|
||||
): boolean {
|
||||
const status = chatRunWatchdogStatus(result);
|
||||
if (status === "pending") {
|
||||
return false;
|
||||
}
|
||||
if (status !== "timeout" && status !== "timed_out") {
|
||||
return true;
|
||||
}
|
||||
if (result?.pendingError === true) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
result?.endedAt != null ||
|
||||
result?.error != null ||
|
||||
result?.stopReason != null ||
|
||||
result?.livenessState != null ||
|
||||
result?.yielded === true ||
|
||||
result?.pendingError === true
|
||||
result?.yielded === true
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2259,6 +2259,47 @@ describe("chat run watchdog", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps retry-grace timeout snapshots active without flushing queued chat", async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const { resetChatRunWatchdog, scheduleChatRunWatchdog } = await import("../app-chat.ts");
|
||||
const request = vi.fn(async (method: string) => {
|
||||
if (method === "agent.wait") {
|
||||
return {
|
||||
status: "timeout",
|
||||
runId: "run-1",
|
||||
error: "agent still starting",
|
||||
pendingError: true,
|
||||
};
|
||||
}
|
||||
throw new Error(`unexpected method: ${method}`);
|
||||
});
|
||||
const host = createWatchdogHost(request);
|
||||
|
||||
scheduleChatRunWatchdog(host as never);
|
||||
await vi.advanceTimersByTimeAsync(15_000);
|
||||
|
||||
expect(host.chatRunId).toBe("run-1");
|
||||
expect(host.chatQueue).toHaveLength(1);
|
||||
expect(request).toHaveBeenCalledWith("agent.wait", {
|
||||
runId: "run-1",
|
||||
timeoutMs: 50,
|
||||
});
|
||||
expect(request).not.toHaveBeenCalledWith(
|
||||
"chat.send",
|
||||
expect.objectContaining({ message: "continue" }),
|
||||
);
|
||||
expect(request).not.toHaveBeenCalledWith(
|
||||
"chat.history",
|
||||
expect.objectContaining({ sessionKey: "main" }),
|
||||
);
|
||||
|
||||
resetChatRunWatchdog(host as never);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("does not surface transient probe failures as chat errors", async () => {
|
||||
vi.useFakeTimers();
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => undefined);
|
||||
|
||||
Reference in New Issue
Block a user