mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-08 11:02:26 +00:00
fix(onboard): cancel custom verification bodies
This commit is contained in:
@@ -108,6 +108,27 @@ describe("promptCustomApiConfig", () => {
|
||||
expect(prompter.confirm).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("cancels custom provider verification response bodies", async () => {
|
||||
const prompter = createTestPrompter({
|
||||
text: ["http://localhost:11434/v1", "", "llama3", "custom", ""],
|
||||
select: ["plaintext", "openai"],
|
||||
});
|
||||
const cancel = vi.fn(async () => undefined);
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn(async () => ({
|
||||
ok: true,
|
||||
status: 200,
|
||||
headers: new Headers({ "content-type": "application/json; charset=utf-8" }),
|
||||
body: { cancel },
|
||||
})),
|
||||
);
|
||||
|
||||
await runPromptCustomApi(prompter);
|
||||
|
||||
expect(cancel).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("handles explicit OpenAI Responses flow", async () => {
|
||||
const prompter = createTestPrompter({
|
||||
text: ["https://proxy.example.com/v1", "test-key", "gpt-5.4", "custom", ""],
|
||||
|
||||
@@ -108,8 +108,9 @@ async function requestVerification(params: {
|
||||
headers: Record<string, string>;
|
||||
body: Record<string, unknown>;
|
||||
}): Promise<VerificationResult> {
|
||||
let res: Response | undefined;
|
||||
try {
|
||||
const res = await fetchWithTimeout(
|
||||
res = await fetchWithTimeout(
|
||||
params.endpoint,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -133,6 +134,8 @@ async function requestVerification(params: {
|
||||
return { ok: res.ok, status: res.status };
|
||||
} catch (error) {
|
||||
return { ok: false, error };
|
||||
} finally {
|
||||
await res?.body?.cancel().catch(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user