Bootstrap Proxy agent if proxy configured

Signed-off-by: enyineer <nico.enking@gmail.com>
This commit is contained in:
enyineer
2025-10-10 09:50:35 +02:00
parent 0a6af3bec1
commit 944d3fa82e
+22
View File
@@ -14,6 +14,8 @@
* limitations under the License.
*/
maybeBootstrapProxy();
import chalk from 'chalk';
import fs from 'fs-extra';
import handlebars from 'handlebars';
@@ -30,6 +32,26 @@ import { packageVersions } from './versions';
import { promisify } from 'util';
import os from 'os';
function maybeBootstrapProxy() {
// see https://www.npmjs.com/package/global-agent
const globalAgentNamespace =
process.env.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE ?? 'GLOBAL_AGENT_';
if (
process.env[`${globalAgentNamespace}HTTP_PROXY`] ||
process.env[`${globalAgentNamespace}HTTPS_PROXY`]
) {
const globalAgent =
require('global-agent') as typeof import('global-agent');
globalAgent.bootstrap();
}
if (process.env.HTTP_PROXY || process.env.HTTPS_PROXY) {
const { setGlobalDispatcher, EnvHttpProxyAgent } =
require('undici') as typeof import('undici');
setGlobalDispatcher(new EnvHttpProxyAgent());
}
}
const TASK_NAME_MAX_LENGTH = 14;
const TEN_MINUTES_MS = 1000 * 60 * 10;
const exec = promisify(execCb);