* Stop storing the log on disk * Add more info to the session logging * Only clear session tokens from storage when they've expired * Retry session resumption a few times if it's a network issue * Improvements to the 'connecting' screen
29 lines
537 B
TypeScript
29 lines
537 B
TypeScript
import {isNetworkError} from 'lib/strings/errors'
|
|
|
|
export async function retry<P>(
|
|
retries: number,
|
|
cond: (err: any) => boolean,
|
|
fn: () => Promise<P>,
|
|
): Promise<P> {
|
|
let lastErr
|
|
while (retries > 0) {
|
|
try {
|
|
return await fn()
|
|
} catch (e: any) {
|
|
lastErr = e
|
|
if (cond(e)) {
|
|
retries--
|
|
continue
|
|
}
|
|
throw e
|
|
}
|
|
}
|
|
throw lastErr
|
|
}
|
|
|
|
export async function networkRetry<P>(
|
|
retries: number,
|
|
fn: () => Promise<P>,
|
|
): Promise<P> {
|
|
return retry(retries, isNetworkError, fn)
|
|
}
|