feat(core): increase fetch timeout and fix [object Object] error stringification (#20441)

Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com>
This commit is contained in:
Bryan Morgan
2026-02-26 18:41:09 -05:00
committed by GitHub
parent b8d6041d42
commit 6dc9d5ff11
4 changed files with 100 additions and 24 deletions

View File

@@ -6,7 +6,18 @@
import { getErrorMessage, isNodeError } from './errors.js';
import { URL } from 'node:url';
import { ProxyAgent, setGlobalDispatcher } from 'undici';
import { Agent, ProxyAgent, setGlobalDispatcher } from 'undici';
const DEFAULT_HEADERS_TIMEOUT = 60000; // 60 seconds
const DEFAULT_BODY_TIMEOUT = 300000; // 5 minutes
// Configure default global dispatcher with higher timeouts
setGlobalDispatcher(
new Agent({
headersTimeout: DEFAULT_HEADERS_TIMEOUT,
bodyTimeout: DEFAULT_BODY_TIMEOUT,
}),
);
const PRIVATE_IP_RANGES = [
/^10\./,
@@ -73,5 +84,11 @@ export async function fetchWithTimeout(
}
export function setGlobalProxy(proxy: string) {
setGlobalDispatcher(new ProxyAgent(proxy));
setGlobalDispatcher(
new ProxyAgent({
uri: proxy,
headersTimeout: DEFAULT_HEADERS_TIMEOUT,
bodyTimeout: DEFAULT_BODY_TIMEOUT,
}),
);
}