fix(proxy): add connection limits and IPv4 support to undici agents

This commit is contained in:
Fallenbagel
2026-01-17 07:07:56 +05:00
parent b55c49c360
commit 46e95317f6

View File

@@ -14,7 +14,11 @@ export default async function createCustomProxyAgent(
proxySettings: ProxySettings,
forceIpv4First?: boolean
) {
const defaultAgent = new Agent({ keepAliveTimeout: 5000 });
const defaultAgent = new Agent({
keepAliveTimeout: 5000,
connections: 50,
connect: forceIpv4First ? { family: 4 } : undefined,
});
const skipUrl = (url: string | URL) => {
const hostname =
@@ -68,6 +72,8 @@ export default async function createCustomProxyAgent(
uri: proxyUrl,
token,
keepAliveTimeout: 5000,
connections: 50,
connect: forceIpv4First ? { family: 4 } : undefined,
});
setGlobalDispatcher(proxyAgent.compose(noProxyInterceptor));