fix: respect no proxy directive (#1037)

Closes #1034
This commit is contained in:
marcel
2026-09-10 20:40:43 +02:00
committed by GitHub
parent 421feb646d
commit b90ec40d15
3 changed files with 52 additions and 84 deletions
Generated Vendored
+23 -34
View File
@@ -8546,7 +8546,7 @@ var require_proxy_agent = __commonJS({
return this.#client.destroy(err); return this.#client.destroy(err);
} }
}; };
var ProxyAgent3 = class extends DispatcherBase { var ProxyAgent2 = class extends DispatcherBase {
constructor(opts) { constructor(opts) {
super(); super();
if (!opts || typeof opts === "object" && !(opts instanceof URL3) && !opts.uri) { if (!opts || typeof opts === "object" && !(opts instanceof URL3) && !opts.uri) {
@@ -8687,7 +8687,7 @@ var require_proxy_agent = __commonJS({
throw new InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor"); throw new InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor");
} }
} }
module2.exports = ProxyAgent3; module2.exports = ProxyAgent2;
} }
}); });
@@ -8697,14 +8697,14 @@ var require_env_http_proxy_agent = __commonJS({
"use strict"; "use strict";
var DispatcherBase = require_dispatcher_base(); var DispatcherBase = require_dispatcher_base();
var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols(); var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols();
var ProxyAgent3 = require_proxy_agent(); var ProxyAgent2 = require_proxy_agent();
var Agent3 = require_agent(); var Agent3 = require_agent();
var DEFAULT_PORTS = { var DEFAULT_PORTS = {
"http:": 80, "http:": 80,
"https:": 443 "https:": 443
}; };
var experimentalWarned = false; var experimentalWarned = false;
var EnvHttpProxyAgent = class extends DispatcherBase { var EnvHttpProxyAgent2 = class extends DispatcherBase {
#noProxyValue = null; #noProxyValue = null;
#noProxyEntries = null; #noProxyEntries = null;
#opts = null; #opts = null;
@@ -8721,13 +8721,13 @@ var require_env_http_proxy_agent = __commonJS({
this[kNoProxyAgent] = new Agent3(agentOpts); this[kNoProxyAgent] = new Agent3(agentOpts);
const HTTP_PROXY2 = httpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY; const HTTP_PROXY2 = httpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY;
if (HTTP_PROXY2) { if (HTTP_PROXY2) {
this[kHttpProxyAgent] = new ProxyAgent3({ ...agentOpts, uri: HTTP_PROXY2 }); this[kHttpProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTP_PROXY2 });
} else { } else {
this[kHttpProxyAgent] = this[kNoProxyAgent]; this[kHttpProxyAgent] = this[kNoProxyAgent];
} }
const HTTPS_PROXY2 = httpsProxy ?? process.env.https_proxy ?? process.env.HTTPS_PROXY; const HTTPS_PROXY2 = httpsProxy ?? process.env.https_proxy ?? process.env.HTTPS_PROXY;
if (HTTPS_PROXY2) { if (HTTPS_PROXY2) {
this[kHttpsProxyAgent] = new ProxyAgent3({ ...agentOpts, uri: HTTPS_PROXY2 }); this[kHttpsProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTPS_PROXY2 });
} else { } else {
this[kHttpsProxyAgent] = this[kHttpProxyAgent]; this[kHttpsProxyAgent] = this[kHttpProxyAgent];
} }
@@ -8823,7 +8823,7 @@ var require_env_http_proxy_agent = __commonJS({
return process.env.no_proxy ?? process.env.NO_PROXY ?? ""; return process.env.no_proxy ?? process.env.NO_PROXY ?? "";
} }
}; };
module2.exports = EnvHttpProxyAgent; module2.exports = EnvHttpProxyAgent2;
} }
}); });
@@ -18458,8 +18458,8 @@ var require_undici = __commonJS({
var Pool = require_pool(); var Pool = require_pool();
var BalancedPool = require_balanced_pool(); var BalancedPool = require_balanced_pool();
var Agent3 = require_agent(); var Agent3 = require_agent();
var ProxyAgent3 = require_proxy_agent(); var ProxyAgent2 = require_proxy_agent();
var EnvHttpProxyAgent = require_env_http_proxy_agent(); var EnvHttpProxyAgent2 = require_env_http_proxy_agent();
var RetryAgent = require_retry_agent(); var RetryAgent = require_retry_agent();
var errors = require_errors(); var errors = require_errors();
var util7 = require_util(); var util7 = require_util();
@@ -18481,8 +18481,8 @@ var require_undici = __commonJS({
module2.exports.Pool = Pool; module2.exports.Pool = Pool;
module2.exports.BalancedPool = BalancedPool; module2.exports.BalancedPool = BalancedPool;
module2.exports.Agent = Agent3; module2.exports.Agent = Agent3;
module2.exports.ProxyAgent = ProxyAgent3; module2.exports.ProxyAgent = ProxyAgent2;
module2.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module2.exports.EnvHttpProxyAgent = EnvHttpProxyAgent2;
module2.exports.RetryAgent = RetryAgent; module2.exports.RetryAgent = RetryAgent;
module2.exports.RetryHandler = RetryHandler; module2.exports.RetryHandler = RetryHandler;
module2.exports.DecoratorHandler = DecoratorHandler; module2.exports.DecoratorHandler = DecoratorHandler;
@@ -40228,7 +40228,7 @@ var require_proxy_agent2 = __commonJS({
return this.#client.destroy(err); return this.#client.destroy(err);
} }
}; };
var ProxyAgent3 = class extends DispatcherBase { var ProxyAgent2 = class extends DispatcherBase {
constructor(opts) { constructor(opts) {
if (!opts || typeof opts === "object" && !(opts instanceof URL) && !opts.uri) { if (!opts || typeof opts === "object" && !(opts instanceof URL) && !opts.uri) {
throw new InvalidArgumentError("Proxy uri is mandatory"); throw new InvalidArgumentError("Proxy uri is mandatory");
@@ -40427,7 +40427,7 @@ var require_proxy_agent2 = __commonJS({
function throwProxyAuthError() { function throwProxyAuthError() {
throw new InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor"); throw new InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor");
} }
module2.exports = ProxyAgent3; module2.exports = ProxyAgent2;
} }
}); });
@@ -40437,13 +40437,13 @@ var require_env_http_proxy_agent2 = __commonJS({
"use strict"; "use strict";
var DispatcherBase = require_dispatcher_base2(); var DispatcherBase = require_dispatcher_base2();
var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols6(); var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols6();
var ProxyAgent3 = require_proxy_agent2(); var ProxyAgent2 = require_proxy_agent2();
var Agent3 = require_agent2(); var Agent3 = require_agent2();
var DEFAULT_PORTS = { var DEFAULT_PORTS = {
"http:": 80, "http:": 80,
"https:": 443 "https:": 443
}; };
var EnvHttpProxyAgent = class extends DispatcherBase { var EnvHttpProxyAgent2 = class extends DispatcherBase {
#noProxyValue = null; #noProxyValue = null;
#noProxyEntries = null; #noProxyEntries = null;
#opts = null; #opts = null;
@@ -40454,13 +40454,13 @@ var require_env_http_proxy_agent2 = __commonJS({
this[kNoProxyAgent] = new Agent3(agentOpts); this[kNoProxyAgent] = new Agent3(agentOpts);
const HTTP_PROXY2 = httpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY; const HTTP_PROXY2 = httpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY;
if (HTTP_PROXY2) { if (HTTP_PROXY2) {
this[kHttpProxyAgent] = new ProxyAgent3({ ...agentOpts, uri: HTTP_PROXY2 }); this[kHttpProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTP_PROXY2 });
} else { } else {
this[kHttpProxyAgent] = this[kNoProxyAgent]; this[kHttpProxyAgent] = this[kNoProxyAgent];
} }
const HTTPS_PROXY2 = httpsProxy ?? process.env.https_proxy ?? process.env.HTTPS_PROXY; const HTTPS_PROXY2 = httpsProxy ?? process.env.https_proxy ?? process.env.HTTPS_PROXY;
if (HTTPS_PROXY2) { if (HTTPS_PROXY2) {
this[kHttpsProxyAgent] = new ProxyAgent3({ ...agentOpts, uri: HTTPS_PROXY2 }); this[kHttpsProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTPS_PROXY2 });
} else { } else {
this[kHttpsProxyAgent] = this[kHttpProxyAgent]; this[kHttpsProxyAgent] = this[kHttpProxyAgent];
} }
@@ -40561,7 +40561,7 @@ var require_env_http_proxy_agent2 = __commonJS({
return process.env.no_proxy ?? process.env.NO_PROXY ?? ""; return process.env.no_proxy ?? process.env.NO_PROXY ?? "";
} }
}; };
module2.exports = EnvHttpProxyAgent; module2.exports = EnvHttpProxyAgent2;
} }
}); });
@@ -55691,9 +55691,9 @@ var require_undici2 = __commonJS({
var RoundRobinPool = require_round_robin_pool(); var RoundRobinPool = require_round_robin_pool();
var Agent3 = require_agent2(); var Agent3 = require_agent2();
var Dispatcher1Wrapper = require_dispatcher1_wrapper(); var Dispatcher1Wrapper = require_dispatcher1_wrapper();
var ProxyAgent3 = require_proxy_agent2(); var ProxyAgent2 = require_proxy_agent2();
var Socks5ProxyAgent = require_socks5_proxy_agent(); var Socks5ProxyAgent = require_socks5_proxy_agent();
var EnvHttpProxyAgent = require_env_http_proxy_agent2(); var EnvHttpProxyAgent2 = require_env_http_proxy_agent2();
var RetryAgent = require_retry_agent2(); var RetryAgent = require_retry_agent2();
var H2CClient = require_h2c_client(); var H2CClient = require_h2c_client();
var errors = require_errors2(); var errors = require_errors2();
@@ -55719,9 +55719,9 @@ var require_undici2 = __commonJS({
module2.exports.RoundRobinPool = RoundRobinPool; module2.exports.RoundRobinPool = RoundRobinPool;
module2.exports.Agent = Agent3; module2.exports.Agent = Agent3;
module2.exports.Dispatcher1Wrapper = Dispatcher1Wrapper; module2.exports.Dispatcher1Wrapper = Dispatcher1Wrapper;
module2.exports.ProxyAgent = ProxyAgent3; module2.exports.ProxyAgent = ProxyAgent2;
module2.exports.Socks5ProxyAgent = Socks5ProxyAgent; module2.exports.Socks5ProxyAgent = Socks5ProxyAgent;
module2.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module2.exports.EnvHttpProxyAgent = EnvHttpProxyAgent2;
module2.exports.RetryAgent = RetryAgent; module2.exports.RetryAgent = RetryAgent;
module2.exports.H2CClient = H2CClient; module2.exports.H2CClient = H2CClient;
module2.exports.RetryHandler = RetryHandler; module2.exports.RetryHandler = RetryHandler;
@@ -99844,23 +99844,12 @@ var import_node_stream5 = require("node:stream");
// src/utils/fetch.ts // src/utils/fetch.ts
var import_undici2 = __toESM(require_undici2(), 1); var import_undici2 = __toESM(require_undici2(), 1);
function getProxyAgent() {
const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;
if (httpProxy) {
return new import_undici2.ProxyAgent(httpProxy);
}
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
if (httpsProxy) {
return new import_undici2.ProxyAgent(httpsProxy);
}
return void 0;
}
var fetch = async (url2, opts) => { var fetch = async (url2, opts) => {
const timeoutSignal = AbortSignal.timeout(5e3); const timeoutSignal = AbortSignal.timeout(5e3);
const existingSignal = opts.signal; const existingSignal = opts.signal;
const mergedSignal = existingSignal ? AbortSignal.any([timeoutSignal, existingSignal]) : timeoutSignal; const mergedSignal = existingSignal ? AbortSignal.any([timeoutSignal, existingSignal]) : timeoutSignal;
return await (0, import_undici2.fetch)(url2, { return await (0, import_undici2.fetch)(url2, {
dispatcher: getProxyAgent(), dispatcher: new import_undici2.EnvHttpProxyAgent(),
...opts, ...opts,
signal: mergedSignal signal: mergedSignal
}); });
+23 -34
View File
@@ -8542,7 +8542,7 @@ var require_proxy_agent = __commonJS({
return this.#client.destroy(err); return this.#client.destroy(err);
} }
}; };
var ProxyAgent3 = class extends DispatcherBase { var ProxyAgent2 = class extends DispatcherBase {
constructor(opts) { constructor(opts) {
super(); super();
if (!opts || typeof opts === "object" && !(opts instanceof URL2) && !opts.uri) { if (!opts || typeof opts === "object" && !(opts instanceof URL2) && !opts.uri) {
@@ -8683,7 +8683,7 @@ var require_proxy_agent = __commonJS({
throw new InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor"); throw new InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor");
} }
} }
module2.exports = ProxyAgent3; module2.exports = ProxyAgent2;
} }
}); });
@@ -8693,14 +8693,14 @@ var require_env_http_proxy_agent = __commonJS({
"use strict"; "use strict";
var DispatcherBase = require_dispatcher_base(); var DispatcherBase = require_dispatcher_base();
var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols(); var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols();
var ProxyAgent3 = require_proxy_agent(); var ProxyAgent2 = require_proxy_agent();
var Agent = require_agent(); var Agent = require_agent();
var DEFAULT_PORTS = { var DEFAULT_PORTS = {
"http:": 80, "http:": 80,
"https:": 443 "https:": 443
}; };
var experimentalWarned = false; var experimentalWarned = false;
var EnvHttpProxyAgent = class extends DispatcherBase { var EnvHttpProxyAgent2 = class extends DispatcherBase {
#noProxyValue = null; #noProxyValue = null;
#noProxyEntries = null; #noProxyEntries = null;
#opts = null; #opts = null;
@@ -8717,13 +8717,13 @@ var require_env_http_proxy_agent = __commonJS({
this[kNoProxyAgent] = new Agent(agentOpts); this[kNoProxyAgent] = new Agent(agentOpts);
const HTTP_PROXY = httpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY; const HTTP_PROXY = httpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY;
if (HTTP_PROXY) { if (HTTP_PROXY) {
this[kHttpProxyAgent] = new ProxyAgent3({ ...agentOpts, uri: HTTP_PROXY }); this[kHttpProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTP_PROXY });
} else { } else {
this[kHttpProxyAgent] = this[kNoProxyAgent]; this[kHttpProxyAgent] = this[kNoProxyAgent];
} }
const HTTPS_PROXY = httpsProxy ?? process.env.https_proxy ?? process.env.HTTPS_PROXY; const HTTPS_PROXY = httpsProxy ?? process.env.https_proxy ?? process.env.HTTPS_PROXY;
if (HTTPS_PROXY) { if (HTTPS_PROXY) {
this[kHttpsProxyAgent] = new ProxyAgent3({ ...agentOpts, uri: HTTPS_PROXY }); this[kHttpsProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTPS_PROXY });
} else { } else {
this[kHttpsProxyAgent] = this[kHttpProxyAgent]; this[kHttpsProxyAgent] = this[kHttpProxyAgent];
} }
@@ -8819,7 +8819,7 @@ var require_env_http_proxy_agent = __commonJS({
return process.env.no_proxy ?? process.env.NO_PROXY ?? ""; return process.env.no_proxy ?? process.env.NO_PROXY ?? "";
} }
}; };
module2.exports = EnvHttpProxyAgent; module2.exports = EnvHttpProxyAgent2;
} }
}); });
@@ -18454,8 +18454,8 @@ var require_undici = __commonJS({
var Pool = require_pool(); var Pool = require_pool();
var BalancedPool = require_balanced_pool(); var BalancedPool = require_balanced_pool();
var Agent = require_agent(); var Agent = require_agent();
var ProxyAgent3 = require_proxy_agent(); var ProxyAgent2 = require_proxy_agent();
var EnvHttpProxyAgent = require_env_http_proxy_agent(); var EnvHttpProxyAgent2 = require_env_http_proxy_agent();
var RetryAgent = require_retry_agent(); var RetryAgent = require_retry_agent();
var errors = require_errors(); var errors = require_errors();
var util = require_util(); var util = require_util();
@@ -18477,8 +18477,8 @@ var require_undici = __commonJS({
module2.exports.Pool = Pool; module2.exports.Pool = Pool;
module2.exports.BalancedPool = BalancedPool; module2.exports.BalancedPool = BalancedPool;
module2.exports.Agent = Agent; module2.exports.Agent = Agent;
module2.exports.ProxyAgent = ProxyAgent3; module2.exports.ProxyAgent = ProxyAgent2;
module2.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module2.exports.EnvHttpProxyAgent = EnvHttpProxyAgent2;
module2.exports.RetryAgent = RetryAgent; module2.exports.RetryAgent = RetryAgent;
module2.exports.RetryHandler = RetryHandler; module2.exports.RetryHandler = RetryHandler;
module2.exports.DecoratorHandler = DecoratorHandler; module2.exports.DecoratorHandler = DecoratorHandler;
@@ -31050,7 +31050,7 @@ var require_proxy_agent2 = __commonJS({
return this.#client.destroy(err); return this.#client.destroy(err);
} }
}; };
var ProxyAgent3 = class extends DispatcherBase { var ProxyAgent2 = class extends DispatcherBase {
constructor(opts) { constructor(opts) {
if (!opts || typeof opts === "object" && !(opts instanceof URL) && !opts.uri) { if (!opts || typeof opts === "object" && !(opts instanceof URL) && !opts.uri) {
throw new InvalidArgumentError("Proxy uri is mandatory"); throw new InvalidArgumentError("Proxy uri is mandatory");
@@ -31249,7 +31249,7 @@ var require_proxy_agent2 = __commonJS({
function throwProxyAuthError() { function throwProxyAuthError() {
throw new InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor"); throw new InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor");
} }
module2.exports = ProxyAgent3; module2.exports = ProxyAgent2;
} }
}); });
@@ -31259,13 +31259,13 @@ var require_env_http_proxy_agent2 = __commonJS({
"use strict"; "use strict";
var DispatcherBase = require_dispatcher_base2(); var DispatcherBase = require_dispatcher_base2();
var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols6(); var { kClose, kDestroy, kClosed, kDestroyed, kDispatch, kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent } = require_symbols6();
var ProxyAgent3 = require_proxy_agent2(); var ProxyAgent2 = require_proxy_agent2();
var Agent = require_agent2(); var Agent = require_agent2();
var DEFAULT_PORTS = { var DEFAULT_PORTS = {
"http:": 80, "http:": 80,
"https:": 443 "https:": 443
}; };
var EnvHttpProxyAgent = class extends DispatcherBase { var EnvHttpProxyAgent2 = class extends DispatcherBase {
#noProxyValue = null; #noProxyValue = null;
#noProxyEntries = null; #noProxyEntries = null;
#opts = null; #opts = null;
@@ -31276,13 +31276,13 @@ var require_env_http_proxy_agent2 = __commonJS({
this[kNoProxyAgent] = new Agent(agentOpts); this[kNoProxyAgent] = new Agent(agentOpts);
const HTTP_PROXY = httpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY; const HTTP_PROXY = httpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY;
if (HTTP_PROXY) { if (HTTP_PROXY) {
this[kHttpProxyAgent] = new ProxyAgent3({ ...agentOpts, uri: HTTP_PROXY }); this[kHttpProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTP_PROXY });
} else { } else {
this[kHttpProxyAgent] = this[kNoProxyAgent]; this[kHttpProxyAgent] = this[kNoProxyAgent];
} }
const HTTPS_PROXY = httpsProxy ?? process.env.https_proxy ?? process.env.HTTPS_PROXY; const HTTPS_PROXY = httpsProxy ?? process.env.https_proxy ?? process.env.HTTPS_PROXY;
if (HTTPS_PROXY) { if (HTTPS_PROXY) {
this[kHttpsProxyAgent] = new ProxyAgent3({ ...agentOpts, uri: HTTPS_PROXY }); this[kHttpsProxyAgent] = new ProxyAgent2({ ...agentOpts, uri: HTTPS_PROXY });
} else { } else {
this[kHttpsProxyAgent] = this[kHttpProxyAgent]; this[kHttpsProxyAgent] = this[kHttpProxyAgent];
} }
@@ -31383,7 +31383,7 @@ var require_env_http_proxy_agent2 = __commonJS({
return process.env.no_proxy ?? process.env.NO_PROXY ?? ""; return process.env.no_proxy ?? process.env.NO_PROXY ?? "";
} }
}; };
module2.exports = EnvHttpProxyAgent; module2.exports = EnvHttpProxyAgent2;
} }
}); });
@@ -46513,9 +46513,9 @@ var require_undici2 = __commonJS({
var RoundRobinPool = require_round_robin_pool(); var RoundRobinPool = require_round_robin_pool();
var Agent = require_agent2(); var Agent = require_agent2();
var Dispatcher1Wrapper = require_dispatcher1_wrapper(); var Dispatcher1Wrapper = require_dispatcher1_wrapper();
var ProxyAgent3 = require_proxy_agent2(); var ProxyAgent2 = require_proxy_agent2();
var Socks5ProxyAgent = require_socks5_proxy_agent(); var Socks5ProxyAgent = require_socks5_proxy_agent();
var EnvHttpProxyAgent = require_env_http_proxy_agent2(); var EnvHttpProxyAgent2 = require_env_http_proxy_agent2();
var RetryAgent = require_retry_agent2(); var RetryAgent = require_retry_agent2();
var H2CClient = require_h2c_client(); var H2CClient = require_h2c_client();
var errors = require_errors2(); var errors = require_errors2();
@@ -46541,9 +46541,9 @@ var require_undici2 = __commonJS({
module2.exports.RoundRobinPool = RoundRobinPool; module2.exports.RoundRobinPool = RoundRobinPool;
module2.exports.Agent = Agent; module2.exports.Agent = Agent;
module2.exports.Dispatcher1Wrapper = Dispatcher1Wrapper; module2.exports.Dispatcher1Wrapper = Dispatcher1Wrapper;
module2.exports.ProxyAgent = ProxyAgent3; module2.exports.ProxyAgent = ProxyAgent2;
module2.exports.Socks5ProxyAgent = Socks5ProxyAgent; module2.exports.Socks5ProxyAgent = Socks5ProxyAgent;
module2.exports.EnvHttpProxyAgent = EnvHttpProxyAgent; module2.exports.EnvHttpProxyAgent = EnvHttpProxyAgent2;
module2.exports.RetryAgent = RetryAgent; module2.exports.RetryAgent = RetryAgent;
module2.exports.H2CClient = H2CClient; module2.exports.H2CClient = H2CClient;
module2.exports.RetryHandler = RetryHandler; module2.exports.RetryHandler = RetryHandler;
@@ -52516,23 +52516,12 @@ var VERSIONS_MANIFEST_URL = "https://raw.githubusercontent.com/astral-sh/version
// src/utils/fetch.ts // src/utils/fetch.ts
var import_undici2 = __toESM(require_undici2(), 1); var import_undici2 = __toESM(require_undici2(), 1);
function getProxyAgent() {
const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;
if (httpProxy) {
return new import_undici2.ProxyAgent(httpProxy);
}
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
if (httpsProxy) {
return new import_undici2.ProxyAgent(httpsProxy);
}
return void 0;
}
var fetch = async (url, opts) => { var fetch = async (url, opts) => {
const timeoutSignal = AbortSignal.timeout(5e3); const timeoutSignal = AbortSignal.timeout(5e3);
const existingSignal = opts.signal; const existingSignal = opts.signal;
const mergedSignal = existingSignal ? AbortSignal.any([timeoutSignal, existingSignal]) : timeoutSignal; const mergedSignal = existingSignal ? AbortSignal.any([timeoutSignal, existingSignal]) : timeoutSignal;
return await (0, import_undici2.fetch)(url, { return await (0, import_undici2.fetch)(url, {
dispatcher: getProxyAgent(), dispatcher: new import_undici2.EnvHttpProxyAgent(),
...opts, ...opts,
signal: mergedSignal signal: mergedSignal
}); });
+6 -16
View File
@@ -1,18 +1,8 @@
import { ProxyAgent, type RequestInit, fetch as undiciFetch } from "undici"; import {
EnvHttpProxyAgent,
export function getProxyAgent() { type RequestInit,
const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy; fetch as undiciFetch,
if (httpProxy) { } from "undici";
return new ProxyAgent(httpProxy);
}
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
if (httpsProxy) {
return new ProxyAgent(httpsProxy);
}
return undefined;
}
export const fetch = async (url: string, opts: RequestInit) => { export const fetch = async (url: string, opts: RequestInit) => {
// Merge timeout signal with any existing signal from opts // Merge timeout signal with any existing signal from opts
@@ -23,7 +13,7 @@ export const fetch = async (url: string, opts: RequestInit) => {
: timeoutSignal; : timeoutSignal;
return await undiciFetch(url, { return await undiciFetch(url, {
dispatcher: getProxyAgent(), dispatcher: new EnvHttpProxyAgent(),
...opts, ...opts,
signal: mergedSignal, signal: mergedSignal,
}); });