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

@ -2,7 +2,6 @@
// SPDX-License-Identifier: AGPL-3.0-only
import URL from 'url';
import ProxyAgent from 'proxy-agent';
import type { RequestInit } from 'node-fetch';
import { Response, Headers } from 'node-fetch';
import type { connection as WebSocket } from 'websocket';
@ -14,6 +13,7 @@ import { strictAssert } from '../util/assert';
import { BackOff, FIBONACCI_TIMEOUTS } from '../util/BackOff';
import * as durations from '../util/durations';
import { sleep } from '../util/sleep';
import { createProxyAgent } from '../util/createProxyAgent';
import { SocketStatus } from '../types/SocketStatus';
import * as Errors from '../types/errors';
import * as Bytes from '../Bytes';
@ -68,7 +68,7 @@ export class SocketManager extends EventListener {
private credentials?: WebAPICredentials;
private readonly proxyAgent?: ReturnType<typeof ProxyAgent>;
private readonly proxyAgent?: ReturnType<typeof createProxyAgent>;
private status = SocketStatus.CLOSED;
@ -84,7 +84,7 @@ export class SocketManager extends EventListener {
super();
if (options.proxyUrl) {
this.proxyAgent = new ProxyAgent(options.proxyUrl);
this.proxyAgent = createProxyAgent(options.proxyUrl);
}
this.hasStoriesDisabled = options.hasStoriesDisabled;