Files
oh-my-pi/packages/coding-agent/src/cli/update-cli.test.ts
T
roboomp 76c480646e fix(cli): added fetch timeouts
Added timeout-backed AbortSignals to update, Hindsight, and Smithery fetch calls so stalled endpoints abort instead of hanging indefinitely.

Added regression coverage for the timeout signals on the exposed command/client paths.

Fixes #4229
2026-07-02 08:39:21 +00:00

29 lines
912 B
TypeScript

import { afterEach, describe, expect, it, vi } from "bun:test";
import { runUpdateCommand } from "./update-cli";
type FetchInput = string | URL | Request;
type FetchInit = RequestInit | BunFetchRequestInit;
describe("runUpdateCommand fetch cancellation", () => {
afterEach(() => {
vi.restoreAllMocks();
});
it("checks release metadata with a timeout signal", async () => {
let requestSignal: AbortSignal | undefined;
vi.spyOn(console, "log").mockImplementation(() => {});
const fetchStub = Object.assign(
async (_input: FetchInput, init?: FetchInit) => {
requestSignal = init?.signal ?? undefined;
return Response.json({ version: "999.0.0" });
},
{ preconnect: globalThis.fetch.preconnect },
);
vi.spyOn(globalThis, "fetch").mockImplementation(fetchStub);
await runUpdateCommand({ force: false, check: true });
expect(requestSignal).toBeInstanceOf(AbortSignal);
});
});