mirror of
https://github.com/supabase/supabase.git
synced 2026-05-07 01:10:15 -04:00
22cfd2be14
* added packages for creating projects * updated scripts * remove ami version * cleaned up common * updated tests * refactored helpers * updated env * updated config * updated to reference env * updated global setup * updated type logic and scripts * added mocking of hcaptcha * added log statements * updated local env * update env file * updated env vars * updated logging * updated to remove check * updated print and project names * updated helpers * updated url * updated setup * updated storage helpers to account for listing files * updated setup and tests * updated timeout only for setup * updated helper to account for different api response * added ignores for tests * updated lock file * updated database spec to add exact * updated timeouts * removed check for table grid footer * updated test runner * updated is_platform * updated playwright config * updated worker settings * removed dotenvx * updated README * updated to remove comment * Update e2e/studio/scripts/common/retriedFetch.ts Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> --------- Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>
25 lines
724 B
TypeScript
25 lines
724 B
TypeScript
import timeoutFetch from './timeoutFetch.js'
|
|
|
|
export default async function retriedFetch(
|
|
input: RequestInfo,
|
|
init?: RequestInit,
|
|
timeout: number = 10000,
|
|
retries: number = 3,
|
|
delayBase: number = 200
|
|
): Promise<Response> {
|
|
for (let i = 0; i < retries; i++) {
|
|
try {
|
|
const res = await timeoutFetch(input, init, timeout)
|
|
if (res.status >= 100 && res.status < 400) {
|
|
return res
|
|
}
|
|
console.log(`Retrying fetch ${i} ${input}`, res.status, res.statusText)
|
|
} catch (e) {
|
|
console.log(`Retrying fetch ${i} ${input}`, e)
|
|
} finally {
|
|
await new Promise((resolve) => setTimeout(resolve, delayBase * (i + 1)))
|
|
}
|
|
}
|
|
return await timeoutFetch(input, init, timeout)
|
|
}
|