@kawaiininja/fetch 1.0.29 → 1.0.30
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,2 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🛡️ CORE FETCH EXECUTOR
|
|
3
|
+
* Implements strict 3-retry logic with 3s delay and auto-timeout.
|
|
4
|
+
*/
|
|
1
5
|
export declare const performFetch: (url: string, method: string, token: string, body?: BodyInit, headers?: HeadersInit, rest?: RequestInit, debug?: boolean, abortSignal?: AbortSignal, apiUrl?: (path: string) => string) => Promise<Response>;
|
|
2
6
|
export declare const parseResponse: (res: Response, parseAs: string) => Promise<any>;
|
|
@@ -4,6 +4,10 @@ import { initializeVault, nativeAuthVault } from "./useFetch.vault";
|
|
|
4
4
|
const TIMEOUT_MS = 15000;
|
|
5
5
|
const RETRY_DELAY_MS = 3000;
|
|
6
6
|
const MAX_ATTEMPTS = 3;
|
|
7
|
+
/**
|
|
8
|
+
* 🛡️ CORE FETCH EXECUTOR
|
|
9
|
+
* Implements strict 3-retry logic with 3s delay and auto-timeout.
|
|
10
|
+
*/
|
|
7
11
|
export const performFetch = async (url, method, token, body, headers, rest, debug, abortSignal, apiUrl) => {
|
|
8
12
|
const _isNative = isNative();
|
|
9
13
|
const isInternal = url.startsWith("/") || (apiUrl && url.startsWith(apiUrl(""))) || false;
|
|
@@ -46,6 +50,7 @@ export const performFetch = async (url, method, token, body, headers, rest, debu
|
|
|
46
50
|
if (abortSignal)
|
|
47
51
|
abortSignal.removeEventListener("abort", onAbort);
|
|
48
52
|
lastError = error;
|
|
53
|
+
// If it's a manual abort, don't retry.
|
|
49
54
|
if (error.name === "AbortError" || attempt === MAX_ATTEMPTS)
|
|
50
55
|
break;
|
|
51
56
|
if (debug)
|