test(api): client envelope/refresh/error tests; docs: README; fix: synchronous single-flight refresh reset

This commit is contained in:
2026-07-07 22:47:02 +08:00
parent 61cb549e72
commit 64fb00590f
2 changed files with 119 additions and 6 deletions
+6 -6
View File
@@ -61,15 +61,15 @@ async function tryRefresh(): Promise<boolean> {
return true
} catch {
return false
} finally {
// allow the next expiry to trigger a fresh attempt
setTimeout(() => {
refreshInFlight = null
}, 0)
}
})()
return refreshInFlight
try {
return await refreshInFlight
} finally {
// reset once settled so the next expiry triggers a fresh attempt
refreshInFlight = null
}
}
async function parseError(res: Response): Promise<ApiError> {