feat: advanced PSAs

This commit is contained in:
TrèsAbhi committed 2023-11-14 13:42:15 -06:00
1 parent ef9f3bd361
commit 02a03b4d68
4 files changed
+87 -12

No files matched your search

+10 -3
View File
@@ -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));
}
}