Skip to content

update proxy configuration #1022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 65 additions & 171 deletions package-lock.json
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -36,13 +36,13 @@
"auth0": "^4.17.0",
"dot-prop": "^5.2.0",
"fs-extra": "^10.1.0",
"global-agent": "^3.0.0",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"mkdirp": "^1.0.4",
"nconf": "^0.12.1",
"promise-pool-executor": "^1.1.1",
"sanitize-filename": "^1.6.3",
"undici": "^7.3.0",
"winston": "^3.17.0",
"yargs": "^15.3.1"
},
15 changes: 11 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node
import { bootstrap } from 'global-agent';

// eslint-disable-next-line import/no-extraneous-dependencies
import { ProxyAgent, setGlobalDispatcher } from 'undici';

import { getParams, CliParams } from './args';
import log from './logger';
@@ -19,12 +21,17 @@ async function run(params: CliParams): Promise<void> {
const MAJOR_NODEJS_VERSION = parseInt(process.version.slice(1).split('.')[0], 10);

if (MAJOR_NODEJS_VERSION < 10) {
// `global-agent` works with Node.js v10 and above.
throw new Error('The --proxy_url option is only supported on Node >= 10');
}

process.env.GLOBAL_AGENT_HTTP_PROXY = proxy;
bootstrap();
process.env.HTTP_PROXY = proxy;

log.debug(`Setting proxy to ${proxy}`);

// moving from `global-agent` to undici due to update on SDK 4.x.x
setGlobalDispatcher(
new ProxyAgent(process.env.HTTP_PROXY)
);
}

log.debug(`Start command ${command}`);