@@ -12,13 +12,25 @@ 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 } = await import ( "undici" ) ;
15+ const { fetch : undiciFetch , Agent, interceptors } = await import ( "undici" ) ;
1616 const undiciAgent = new Agent ( {
1717 allowH2 : true ,
18- connections : 1 ,
19- keepAliveTimeout : 500 ,
20- //keepAliveMaxTimeout: 1000 * 60 * 10,
21- } ) ;
18+ // connections: 1,
19+ // keepAliveTimeout: 500,
20+ // clientTtl: 500,
21+ // keepAliveMaxTimeout: 1000 * 60 * 10,
22+ } ) . compose (
23+ interceptors . retry ( {
24+ //maxRetries: 3, // Maximum number of retries (default: 5)
25+ //minTimeout: 1000, // Minimum time to wait before retrying (default: 500ms)
26+ //maxTimeout: 60000, // Maximum time to wait before retrying (default: 30000ms)
27+ //timeoutFactor: 2, // Factor to multiply the timeout by for each retry (default: 2)
28+ //retryAfter: true, // Automatically retry if Retry-After header is present (default: true)
29+ methods : [ "GET" , "PUT" , "HEAD" , "POST" , "DELETE" , "PATCH" , "OPTIONS" ] , // HTTP methods to retry (default includes GET, PUT, HEAD, OPTIONS, DELETE)
30+ //statusCodes: [429, 500, 502], // HTTP status codes to retry (default includes 429, 500, 502, 503, 504)
31+ errorCodes : [ "ECONNRESET" ] , // Error codes to retry (default includes common network errors)
32+ } )
33+ ) ;
2234
2335 return ( ( input : RequestInfo , init ?: RequestInit ) =>
2436 undiciFetch ( input , { ...init , dispatcher : undiciAgent } ) ) as FetchFn ;
0 commit comments