unfee 1.0.4 → 1.0.5
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/dist/index.js +16 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -204,11 +204,13 @@ async function handleFetchError(response, request, ctx, error, retryCount) {
|
|
|
204
204
|
ctx.hooks.onRequestRetry[0]?.(retryCount, response, request, ctx.options);
|
|
205
205
|
ctx.hooks.onRequestRetry[1]?.(retryCount, response, request, ctx.options);
|
|
206
206
|
if (ctx.retry.delay > 0) await new Promise((resolve) => setTimeout(resolve, ctx.retry.delay));
|
|
207
|
+
return;
|
|
207
208
|
}
|
|
208
209
|
} else {
|
|
209
210
|
ctx.hooks.onRequestError[0]?.(error, request, ctx.options);
|
|
210
211
|
ctx.hooks.onRequestError[1]?.(error, request, ctx.options);
|
|
211
212
|
}
|
|
213
|
+
throw error;
|
|
212
214
|
}
|
|
213
215
|
function createFetch(extendOptions) {
|
|
214
216
|
const $fetch = async function(input, options = {}) {
|
|
@@ -229,9 +231,21 @@ function createFetch(extendOptions) {
|
|
|
229
231
|
try {
|
|
230
232
|
inflight = await fetch(request);
|
|
231
233
|
if (!inflight.ok) throw new HTTPError(inflight, request, context.options);
|
|
232
|
-
return
|
|
234
|
+
return [
|
|
235
|
+
null,
|
|
236
|
+
await createFetchResponse(inflight, request, context),
|
|
237
|
+
inflight
|
|
238
|
+
];
|
|
233
239
|
} catch (error) {
|
|
234
|
-
|
|
240
|
+
try {
|
|
241
|
+
await handleFetchError(inflight, request, context, error, retryCount);
|
|
242
|
+
} catch (error) {
|
|
243
|
+
return [
|
|
244
|
+
error,
|
|
245
|
+
null,
|
|
246
|
+
inflight ?? null
|
|
247
|
+
];
|
|
248
|
+
}
|
|
235
249
|
} finally {
|
|
236
250
|
clearTimeout(timer);
|
|
237
251
|
}
|