feat(core): implement experimental direct web fetch (#19557)

This commit is contained in:
Michael Bleigh
2026-02-23 11:50:14 -08:00
committed by GitHub
parent 7cfbb6fb71
commit 70336e73b1
14 changed files with 744 additions and 65 deletions

View File

@@ -41,12 +41,26 @@ export function isPrivateIp(url: string): boolean {
export async function fetchWithTimeout(
url: string,
timeout: number,
options?: RequestInit,
): Promise<Response> {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), timeout);
if (options?.signal) {
if (options.signal.aborted) {
controller.abort();
} else {
options.signal.addEventListener('abort', () => controller.abort(), {
once: true,
});
}
}
try {
const response = await fetch(url, { signal: controller.signal });
const response = await fetch(url, {
...options,
signal: controller.signal,
});
return response;
} catch (error) {
if (isNodeError(error) && error.code === 'ABORT_ERR') {