fix: 修复ipv6未开启情况下,请求带有ipv6地址域名报ETIMEDOUT的bug

This commit is contained in:
xiaojunnuo
2024-11-12 11:14:48 +08:00
parent 7bbaa3806b
commit a9a0967a6f
2 changed files with 8 additions and 20 deletions

View File

@@ -207,6 +207,14 @@ export type CreateAgentOptions = {
httpsProxy?: string;
} & nodeHttp.AgentOptions;
export function createAgent(opts: CreateAgentOptions = {}) {
opts = merge(
{
autoSelectFamily: true,
autoSelectFamilyAttemptTimeout: 2000,
},
opts
);
let httpAgent, httpsAgent;
const httpProxy = opts.httpProxy || process.env.HTTP_PROXY || process.env.http_proxy;
if (httpProxy) {