feat(spf): multi cdn failover (#1671)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Christian Pillsbury
2026-06-17 08:20:43 -07:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 33873bc4ae
commit b89f1e944c
29 changed files with 1508 additions and 248 deletions
+17
View File
@@ -124,6 +124,23 @@ export function getResponseText(response: ResponseLike): Promise<string> {
return response.text();
}
/**
* Fetch a resource and resolve its text body — the text analog of
* {@link FetchBytes}. A non-OK status rejects, so HTTP failures surface as
* rejections that callers (and decorators like the failover tracker) handle
* uniformly with network errors.
*/
export type FetchText = (addressable: Resource, options?: RequestInit) => Promise<string>;
/** Default {@link FetchText}: fetch the resource, reject on non-OK, return text. */
export const fetchResolvableText: FetchText = async (addressable, options) => {
const response = await fetchResolvable(addressable, options);
if (!response.ok) {
throw new Error(`fetchResolvableText: ${response.status} ${response.statusText} for ${addressable.url}`);
}
return getResponseText(response);
};
/**
* Two-stage fetch helper: eagerly starts the HTTP request (TTFB is awaited),
* then returns a lazy iterable over the response body. Separating connection