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

@@ -19,6 +19,7 @@ import type {
UsageProviderId,
UsageSummary,
} from "./provider-usage.types.js";
import { resolveFetch } from "./fetch.js";
type UsageSummaryOptions = {
now?: number;
@@ -34,7 +35,10 @@ export async function loadProviderUsageSummary(
): Promise<UsageSummary> {
const now = opts.now ?? Date.now();
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
const fetchFn = opts.fetch ?? fetch;
const fetchFn = resolveFetch(opts.fetch);
if (!fetchFn) {
throw new Error("fetch is not available");
}
const auths = await resolveProviderAuths({
providers: opts.providers ?? usageProviders,