From 9af90b2ebccd028c9fe784b0d360d62f3b5720d0 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Thu, 17 Oct 2024 12:03:19 +0800 Subject: [PATCH] Use normal agent over `EnvHttpProxyAgent` --- Build/lib/fetch-retry.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Build/lib/fetch-retry.ts b/Build/lib/fetch-retry.ts index 929026ff..58fbb028 100644 --- a/Build/lib/fetch-retry.ts +++ b/Build/lib/fetch-retry.ts @@ -1,7 +1,7 @@ import picocolors from 'picocolors'; import undici, { interceptors, - EnvHttpProxyAgent, + Agent, setGlobalDispatcher } from 'undici'; @@ -19,7 +19,7 @@ import { inspect } from 'node:util'; const cacheableLookup = new CacheableLookup(); -const agent = new EnvHttpProxyAgent({ +const agent = new Agent({ connect: { lookup(hostname, opt, cb) { return cacheableLookup.lookup(hostname, opt as CacheableLookupOptions, cb); @@ -101,6 +101,7 @@ setGlobalDispatcher(agent.compose( ? Math.min(retryAfter, maxTimeout) : Math.min(minTimeout * (timeoutFactor ** (counter - 1)), maxTimeout); + console.log('[fetch retry]', 'schedule retry', { statusCode, retryTimeout, errorCode, url: opts.origin }); // eslint-disable-next-line sukka/prefer-timer-id -- won't leak setTimeout(() => cb(null), retryTimeout); }