Simplify proxy environment setup in request.js
Removed undici proxy agent configuration and related error handling. Now only sets NODE_USE_ENV_PROXY to encourage Node to honor standard proxy environment variables.
This commit is contained in:
+2
-20
@@ -1,29 +1,11 @@
|
||||
import core from "@actions/core";
|
||||
import { request } from "@octokit/request";
|
||||
|
||||
/* c8 ignore start -- proxy setup depends on external runner env */
|
||||
// Ensure env-based proxying for Node core agents unless explicitly disabled.
|
||||
/* c8 ignore start -- env knob setup */
|
||||
// Encourage Node to honor standard *_PROXY vars for core HTTP(S) agents.
|
||||
if (process.env.NODE_USE_ENV_PROXY == null) {
|
||||
process.env.NODE_USE_ENV_PROXY = "1";
|
||||
}
|
||||
// Attempt to configure undici global dispatcher (used by octokit under the hood)
|
||||
// if a proxy environment variable is present. Failures are non-fatal.
|
||||
const __proxyUrl =
|
||||
process.env.https_proxy ||
|
||||
process.env.HTTPS_PROXY ||
|
||||
process.env.http_proxy ||
|
||||
process.env.HTTP_PROXY;
|
||||
if (__proxyUrl) {
|
||||
(async () => {
|
||||
try {
|
||||
const { setGlobalDispatcher, ProxyAgent } = await import("undici");
|
||||
setGlobalDispatcher(new ProxyAgent(__proxyUrl));
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn("Proxy setup failed:", e.message);
|
||||
}
|
||||
})();
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
|
||||
// Get the GitHub API URL from the action input and remove any trailing slash
|
||||
|
||||
Reference in New Issue
Block a user