@owox/internal-helpers 0.16.0-next-20251212073834 → 0.16.0-next-20251212100402
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function fetchWithBackoff(url: string, options: RequestInit,
|
|
1
|
+
export declare function fetchWithBackoff(url: string, options: RequestInit, timeoutMs?: number, maxRetries?: number, initialDelay?: number): Promise<Response>;
|
|
2
2
|
export declare function fetchWithTimeout(url: string, options?: RequestInit, timeoutMs?: number): Promise<Response>;
|
|
3
3
|
//# sourceMappingURL=fetchWithBackoff.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchWithBackoff.d.ts","sourceRoot":"","sources":["../../src/utils/fetchWithBackoff.ts"],"names":[],"mappings":"AAIA,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,EACpB,UAAU,SAAI,EACd,YAAY,SAAM,
|
|
1
|
+
{"version":3,"file":"fetchWithBackoff.d.ts","sourceRoot":"","sources":["../../src/utils/fetchWithBackoff.ts"],"names":[],"mappings":"AAIA,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,EACpB,SAAS,SAAS,EAClB,UAAU,SAAI,EACd,YAAY,SAAM,GACjB,OAAO,CAAC,QAAQ,CAAC,CAuCnB;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,WAAgB,EACzB,SAAS,SAAS,GACjB,OAAO,CAAC,QAAQ,CAAC,CAWnB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LoggerFactory } from '../logging/logger-factory.js';
|
|
2
2
|
import { castError } from './castError.js';
|
|
3
3
|
import { formatDuration } from './formatDuration.js';
|
|
4
|
-
export async function fetchWithBackoff(url, options,
|
|
4
|
+
export async function fetchWithBackoff(url, options, timeoutMs = 25_000, maxRetries = 3, initialDelay = 300) {
|
|
5
5
|
const logger = LoggerFactory.createNamedLogger('fetchWithBackoff');
|
|
6
6
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
7
7
|
try {
|
|
@@ -24,8 +24,6 @@ export async function fetchWithBackoff(url, options, maxRetries = 3, initialDela
|
|
|
24
24
|
const isTransient = msg.includes('EPIPE') ||
|
|
25
25
|
msg.includes('ECONNRESET') ||
|
|
26
26
|
msg.includes('fetch failed') ||
|
|
27
|
-
msg.includes('timed out') ||
|
|
28
|
-
msg.includes('Fetch timeout') ||
|
|
29
27
|
msg.includes('socket hang up');
|
|
30
28
|
if (!isTransient || attempt === maxRetries)
|
|
31
29
|
throw err;
|