mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 17:14:06 +00:00
fix(codex): clamp turn collector timeout
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { MAX_TIMER_TIMEOUT_MS } from "openclaw/plugin-sdk/number-runtime";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { createCodexConversationTurnCollector } from "./conversation-turn-collector.js";
|
||||
|
||||
@@ -188,4 +189,24 @@ describe("codex conversation turn collector", () => {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("clamps oversized turn wait timers", async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const setTimeoutSpy = vi.spyOn(globalThis, "setTimeout");
|
||||
const collector = createCodexConversationTurnCollector("thread-1");
|
||||
collector.setTurnId("turn-1");
|
||||
const completion = collector.wait({ timeoutMs: MAX_TIMER_TIMEOUT_MS + 1 });
|
||||
|
||||
expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS);
|
||||
collector.handleNotification({
|
||||
method: "turn/completed",
|
||||
params: { threadId: "thread-1", turn: { id: "turn-1", status: "completed", items: [] } },
|
||||
});
|
||||
|
||||
await expect(completion).resolves.toEqual({ replyText: "" });
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
||||
import { asOptionalRecord as readRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
||||
import {
|
||||
readCodexNotificationThreadId,
|
||||
@@ -143,7 +144,7 @@ export function createCodexConversationTurnCollector(threadId: string) {
|
||||
reject(new Error("codex app-server bound turn timed out"));
|
||||
clearWaitState();
|
||||
},
|
||||
Math.max(100, params.timeoutMs),
|
||||
resolveTimerTimeoutMs(params.timeoutMs, 100, 100),
|
||||
);
|
||||
timeout.unref?.();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user