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:
Paul Frazee 2023-03-15 15:05:13 -05:00 committed by GitHub
parent 94741cdded
commit 3c05a08482
5 changed files with 100 additions and 48 deletions

29
src/lib/async/retry.ts Normal file
View file

@ -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)
}