Skip to content

Commit f4a447f

Browse files
committed
Don't use undici's globalDispatcher
1 parent a1f64c6 commit f4a447f

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

packages/hardhat-core/src/internal/util/download.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ export async function download(
2424
timeoutMillis = 10000,
2525
extraHeaders: { [name: string]: string } = {}
2626
) {
27-
const { getGlobalDispatcher, ProxyAgent, request } = await import("undici");
27+
const { Agent, ProxyAgent, request } = await import("undici");
2828

2929
let dispatcher: Dispatcher;
3030
if (process.env.http_proxy !== undefined && shouldUseProxy(url)) {
3131
dispatcher = new ProxyAgent(process.env.http_proxy);
3232
} else {
33-
dispatcher = getGlobalDispatcher();
33+
dispatcher = new Agent();
3434
}
3535

3636
const hardhatVersion = getHardhatVersion();

packages/hardhat-verify/src/internal/undici.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ export async function sendPostRequest(
2929
}
3030

3131
function getDispatcher(): Undici.Dispatcher {
32-
const { ProxyAgent, getGlobalDispatcher } =
33-
require("undici") as typeof Undici;
32+
const { ProxyAgent, Agent } = require("undici") as typeof Undici;
3433
if (process.env.http_proxy !== undefined) {
3534
return new ProxyAgent(process.env.http_proxy);
3635
}
3736

38-
return getGlobalDispatcher();
37+
return new Agent();
3938
}
4039

4140
export function isSuccessStatusCode(statusCode: number): boolean {

0 commit comments

Comments
 (0)