mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-22 21:13:34 +00:00
Merge pull request #19779 from overleaf/jpa-e2e-retries
[server-pro] tests: add 5 retries to host-admin requests GitOrigin-RevId: 1a1df58c37b14139e09c66d3306d04b4bc667690
This commit is contained in:
parent
37f486ca9a
commit
051089d466
1 changed files with 18 additions and 1 deletions
|
@ -35,7 +35,18 @@ async function fetchJSON<T = { stdout: string; stderr: string }>(
|
|||
if (init?.body) {
|
||||
init.headers = { 'Content-Type': 'application/json' }
|
||||
}
|
||||
const res = await fetch(input, init)
|
||||
let res
|
||||
for (let attempt = 0; attempt < 5; attempt++) {
|
||||
try {
|
||||
res = await fetch(input, init)
|
||||
break
|
||||
} catch {
|
||||
await sleep(3_000)
|
||||
}
|
||||
}
|
||||
if (!res) {
|
||||
res = await fetch(input, init)
|
||||
}
|
||||
const { error, stdout, stderr, ...rest } = await res.json()
|
||||
if (error) {
|
||||
console.error(input, init, 'failed:', error)
|
||||
|
@ -73,3 +84,9 @@ export async function getRedisKeys() {
|
|||
})
|
||||
return stdout.split('\n')
|
||||
}
|
||||
|
||||
async function sleep(ms: number) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, ms)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue