Files
oh-my-pi/packages/coding-agent/src/utils/fetch-timeout.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

11 lines
494 B
TypeScript

/** Create an abort signal that fires after a timeout and preserves caller cancellation. */
export function withTimeoutSignal(timeoutMs: number, signal?: AbortSignal): AbortSignal {
const timeoutSignal = AbortSignal.timeout(timeoutMs);
return signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
}
/** Detect a timeout raised by an abortable fetch. */
export function isTimeoutError(error: unknown): boolean {
return error instanceof Error && error.name === "TimeoutError";
}