mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 03:29:51 +02:00
feat: advanced PSAs
This commit is contained in:
1 parent
ef9f3bd361
commit
02a03b4d68
4 files changed
+87
-12
No files matched your search
@@ -1,11 +1,18 @@
|
||||
export async function patientFetch(url: string, timeout = 1000) {
|
||||
export async function patientFetch(
|
||||
url: string,
|
||||
timeout = 1000,
|
||||
options?: Partial<{ cache: 'no-store' }>,
|
||||
) {
|
||||
let patientResponse: Response;
|
||||
|
||||
while (patientResponse! === undefined) {
|
||||
try {
|
||||
patientResponse = await fetch(url);
|
||||
patientResponse = await fetch(url, options);
|
||||
} catch (error) {
|
||||
console.warn(`Failed to fetch ${url}; retrying in ${timeout}ms...`);
|
||||
console.warn(
|
||||
`Failed to fetch ${url}; retrying in ${timeout}ms...`,
|
||||
error,
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, timeout));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user