@@ -12,30 +12,8 @@ export const resolveFetchFn = async (
1212 try {
1313 // eslint-disable-next-line
1414 // @ts -ignore since undici is an optional dependency and could me missing
15- const { fetch : undiciFetch , Agent, interceptors } = await import ( "undici" ) ;
16- const undiciAgent = new Agent ( {
17- allowH2 : true ,
18- //connections: 1,
19- //keepAliveTimeout: 500,
20- //clientTtl: 500,
21- //keepAliveMaxTimeout: 1000 * 60 * 10,
22- //pipelining: 1,
23- connect : {
24- rejectUnauthorized : true , // Ensure TLS validation
25- secureProtocol : "TLSv1_2_method" , // Use TLS 1.2
26- } ,
27- } ) . compose (
28- interceptors . retry ( {
29- maxRetries : 10 , // Maximum number of retries (default: 5)
30- minTimeout : 2000 , // Minimum time to wait before retrying (default: 500ms)
31- maxTimeout : 60000 , // Maximum time to wait before retrying (default: 30000ms)
32- timeoutFactor : 2 , // Factor to multiply the timeout by for each retry (default: 2)
33- //retryAfter: true, // Automatically retry if Retry-After header is present (default: true)
34- methods : [ "GET" , "PUT" , "HEAD" , "POST" , "DELETE" , "PATCH" , "OPTIONS" ] , // HTTP methods to retry (default includes GET, PUT, HEAD, OPTIONS, DELETE)
35- //statusCodes: [429, 500, 502], // HTTP status codes to retry (default includes 429, 500, 502, 503, 504)
36- errorCodes : [ "ECONNRESET" , "read ECONNRESET" ] , // Error codes to retry (default includes common network errors)
37- } )
38- ) ;
15+ const { fetch : undiciFetch , Agent } = await import ( "undici" ) ;
16+ const undiciAgent = new Agent ( { allowH2 : true } ) ;
3917
4018 return ( ( input : RequestInfo , init ?: RequestInit ) =>
4119 undiciFetch ( input , { ...init , dispatcher : undiciAgent } ) ) as FetchFn ;
0 commit comments