mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-20 23:32:14 +00:00
uberf-7765: only retry network errors when loading config for desktop app (#6274)
Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
parent
b6bb2b7a0c
commit
ce9a30a3ff
@ -19,21 +19,27 @@ export function concatLink (host: string, path: string): string {
|
|||||||
|
|
||||||
async function loadServerConfig (url: string): Promise<any> {
|
async function loadServerConfig (url: string): Promise<any> {
|
||||||
let retries = 5
|
let retries = 5
|
||||||
let error: any
|
let res: Response | undefined
|
||||||
|
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
return await (await fetch(url)).json()
|
res = await fetch(url)
|
||||||
|
break
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e
|
|
||||||
retries--
|
retries--
|
||||||
if (retries > 0) {
|
if (retries === 0) {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000 * (5 - retries)))
|
throw new Error(`Failed to load server config: ${e}`)
|
||||||
}
|
}
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 1000 * (5 - retries)))
|
||||||
}
|
}
|
||||||
} while (retries > 0)
|
} while (retries > 0)
|
||||||
|
|
||||||
throw new Error(`Failed to load server config: ${error}`)
|
if (res === undefined) {
|
||||||
|
// In theory should never get here
|
||||||
|
throw new Error('Failed to load server config')
|
||||||
|
}
|
||||||
|
|
||||||
|
return await res.json()
|
||||||
}
|
}
|
||||||
|
|
||||||
const openArg = (process.argv.find((it) => it.startsWith('--open=')) ?? '').split('--open=')[1]
|
const openArg = (process.argv.find((it) => it.startsWith('--open=')) ?? '').split('--open=')[1]
|
||||||
|
Loading…
Reference in New Issue
Block a user