Logout bug hunt (#294)
* 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
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user