@oh-my-pi/pi-utils 16.0.4 → 16.0.6
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.
- package/package.json +2 -2
- package/src/fetch-retry.ts +4 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/pi-utils",
|
|
4
|
-
"version": "16.0.
|
|
4
|
+
"version": "16.0.6",
|
|
5
5
|
"description": "Shared utilities for pi packages",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"fmt": "biome format --write ."
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@oh-my-pi/pi-natives": "16.0.
|
|
34
|
+
"@oh-my-pi/pi-natives": "16.0.6",
|
|
35
35
|
"beautiful-mermaid": "^1.1.3",
|
|
36
36
|
"handlebars": "^4.7.9",
|
|
37
37
|
"winston": "^3.19.0",
|
package/src/fetch-retry.ts
CHANGED
|
@@ -161,6 +161,7 @@ export async function fetchWithRetry(
|
|
|
161
161
|
defaultDelayMs,
|
|
162
162
|
prepareInit,
|
|
163
163
|
fetch: fetchImpl = fetch,
|
|
164
|
+
timeout = false,
|
|
164
165
|
...baseInit
|
|
165
166
|
} = options;
|
|
166
167
|
const signal = baseInit.signal as AbortSignal | undefined;
|
|
@@ -168,7 +169,7 @@ export async function fetchWithRetry(
|
|
|
168
169
|
for (let attempt = 0; ; attempt++) {
|
|
169
170
|
if (signal?.aborted) throw new Error("Request was aborted");
|
|
170
171
|
const requestUrl = typeof url === "function" ? url(attempt) : url;
|
|
171
|
-
const init = prepareInit ? mergeInit(baseInit, await prepareInit(attempt)) : baseInit;
|
|
172
|
+
const init = prepareInit ? mergeInit(baseInit, await prepareInit(attempt), timeout) : baseInit;
|
|
172
173
|
|
|
173
174
|
let response: Response;
|
|
174
175
|
try {
|
|
@@ -192,8 +193,8 @@ export async function fetchWithRetry(
|
|
|
192
193
|
}
|
|
193
194
|
}
|
|
194
195
|
|
|
195
|
-
function mergeInit(base: RequestInit, overlay: RequestInit): RequestInit {
|
|
196
|
-
const merged
|
|
196
|
+
function mergeInit(base: RequestInit, overlay: RequestInit, timeout: number | false): RequestInit {
|
|
197
|
+
const merged = { ...base, ...overlay, timeout } as unknown as RequestInit;
|
|
197
198
|
if (base.headers || overlay.headers) {
|
|
198
199
|
const baseHeaders = new Headers(base.headers ?? undefined);
|
|
199
200
|
const overlayHeaders = new Headers(overlay.headers ?? undefined);
|