76c480646e
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
11 lines
494 B
TypeScript
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";
|
|
}
|