mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 17:20:35 +08:00
Use normal agent over EnvHttpProxyAgent
This commit is contained in:
parent
93d554b220
commit
9af90b2ebc
@ -1,7 +1,7 @@
|
|||||||
import picocolors from 'picocolors';
|
import picocolors from 'picocolors';
|
||||||
import undici, {
|
import undici, {
|
||||||
interceptors,
|
interceptors,
|
||||||
EnvHttpProxyAgent,
|
Agent,
|
||||||
setGlobalDispatcher
|
setGlobalDispatcher
|
||||||
} from 'undici';
|
} from 'undici';
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ import { inspect } from 'node:util';
|
|||||||
|
|
||||||
const cacheableLookup = new CacheableLookup();
|
const cacheableLookup = new CacheableLookup();
|
||||||
|
|
||||||
const agent = new EnvHttpProxyAgent({
|
const agent = new Agent({
|
||||||
connect: {
|
connect: {
|
||||||
lookup(hostname, opt, cb) {
|
lookup(hostname, opt, cb) {
|
||||||
return cacheableLookup.lookup(hostname, opt as CacheableLookupOptions, cb);
|
return cacheableLookup.lookup(hostname, opt as CacheableLookupOptions, cb);
|
||||||
@ -101,6 +101,7 @@ setGlobalDispatcher(agent.compose(
|
|||||||
? Math.min(retryAfter, maxTimeout)
|
? Math.min(retryAfter, maxTimeout)
|
||||||
: Math.min(minTimeout * (timeoutFactor ** (counter - 1)), 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
|
// eslint-disable-next-line sukka/prefer-timer-id -- won't leak
|
||||||
setTimeout(() => cb(null), retryTimeout);
|
setTimeout(() => cb(null), retryTimeout);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user