fix: assign the keep-alive value explicitly (#1368)

* fix: assign the keep-alive value explicitly

The Node.js documentation mentions that the default keep-alive value is not used when creating a
global agent manually, which is done in customProxyAgent.ts.

re #1365

* fix: typo
This commit is contained in:
Gauthier
2025-02-17 20:48:37 +01:00
committed by GitHub
parent c181cee328
commit 438ccfe9c3

View File

@@ -6,7 +6,7 @@ import { Agent, ProxyAgent, setGlobalDispatcher } from 'undici';
export default async function createCustomProxyAgent( export default async function createCustomProxyAgent(
proxySettings: ProxySettings proxySettings: ProxySettings
) { ) {
const defaultAgent = new Agent(); const defaultAgent = new Agent({ keepAliveTimeout: 5000 });
const skipUrl = (url: string) => { const skipUrl = (url: string) => {
const hostname = new URL(url).hostname; const hostname = new URL(url).hostname;
@@ -63,6 +63,7 @@ export default async function createCustomProxyAgent(
interceptors: { interceptors: {
Client: [noProxyInterceptor], Client: [noProxyInterceptor],
}, },
keepAliveTimeout: 5000,
}); });
setGlobalDispatcher(proxyAgent); setGlobalDispatcher(proxyAgent);