Support Happy Eyeballs in proxy-agent

This commit is contained in:
Fedor Indutny 2023-08-30 01:58:48 +02:00 committed by GitHub
parent eae9e570fc
commit 56ba8fea4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 419 additions and 289 deletions

View file

@ -3,13 +3,13 @@
import type { StrictOptions as GotOptions } from 'got';
import config from 'config';
import ProxyAgent from 'proxy-agent';
import { Agent as HTTPAgent } from 'http';
import * as packageJson from '../../package.json';
import { getUserAgent } from '../util/getUserAgent';
import * as durations from '../util/durations';
import { createHTTPSAgent } from '../util/createHTTPSAgent';
import { createProxyAgent } from '../util/createProxyAgent';
export const GOT_CONNECT_TIMEOUT = durations.MINUTE;
export const GOT_LOOKUP_TIMEOUT = durations.MINUTE;
@ -29,8 +29,8 @@ export function getGotOptions(): GotOptions {
const proxyUrl = getProxyUrl();
const agent = proxyUrl
? {
http: new ProxyAgent(proxyUrl),
https: new ProxyAgent(proxyUrl),
http: createProxyAgent(proxyUrl),
https: createProxyAgent(proxyUrl),
}
: {
http: new HTTPAgent(),