Fix auth timeout on space join, bump welshman

This commit is contained in:
Jon Staab
2024-11-14 13:45:38 -08:00
parent 1b4819c8ad
commit 8caab03e2f
4 changed files with 26 additions and 21 deletions
+13 -7
View File
@@ -305,11 +305,11 @@ export const checkRelayConnection = async (url: string) => {
}
}
export const checkRelayAuth = async (url: string) => {
export const checkRelayAuth = async (url: string, timeout = 3000) => {
const connection = ctx.net.pool.get(url)
const okStatuses = [AuthStatus.None, AuthStatus.Ok]
await connection.auth.attempt(30_000)
await connection.auth.attempt(timeout)
// Only raise an error if it's not a timeout.
// If it is, odds are the problem is with our signer, not the relay
@@ -318,11 +318,17 @@ export const checkRelayAuth = async (url: string) => {
}
}
export const attemptRelayAccess = async (url: string, claim = "") =>
(await checkRelayProfile(url)) ||
(await checkRelayConnection(url)) ||
(await checkRelayAccess(url, claim)) ||
(await checkRelayAuth(url))
export const attemptRelayAccess = async (url: string, claim = "") => {
const checks = [checkRelayProfile, checkRelayConnection, checkRelayAccess, checkRelayAuth]
for (const check of checks) {
const error = await check(url)
if (error) {
return error
}
}
}
// Actions