fix: normalize abort signals for fetch

This commit is contained in:
Peter Steinberger
2026-01-21 17:29:39 +00:00
parent 8aca606a6f
commit 4e1806947d
8 changed files with 81 additions and 9 deletions

View File

@@ -28,3 +28,9 @@ export function wrapFetchWithAbortSignal(fetchImpl: typeof fetch): typeof fetch
}) as typeof fetch;
return Object.assign(wrapped, fetchImpl);
}
export function resolveFetch(fetchImpl?: typeof fetch): typeof fetch | undefined {
const resolved = fetchImpl ?? globalThis.fetch;
if (!resolved) return undefined;
return wrapFetchWithAbortSignal(resolved);
}