Fix #202 slow-network invite timeout handling #207
@@ -25,34 +25,36 @@
|
||||
const authError = deriveRelayAuthError(url)
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const copyInvite = () => clip(invite)
|
||||
|
||||
let claim = $state("")
|
||||
let loading = $state(true)
|
||||
|
||||
let invite = $state("")
|
||||
|
||||
$effect(() => {
|
||||
const relay = displayRelayUrl(url)
|
||||
const params = new URLSearchParams({r: relay, c: claim}).toString()
|
||||
|
||||
invite = PLATFORM_URL + "/join?" + params
|
||||
})
|
||||
|
||||
onMount(async () => {
|
||||
const [[event]] = await Promise.all([
|
||||
request({
|
||||
relays: [url],
|
||||
autoClose: true,
|
||||
signal: AbortSignal.timeout(3000),
|
||||
filters: [{kinds: [RELAY_INVITE]}],
|
||||
}),
|
||||
sleep(2000),
|
||||
])
|
||||
try {
|
||||
const [[event]] = await Promise.all([
|
||||
request({
|
||||
relays: [url],
|
||||
autoClose: true,
|
||||
signal: AbortSignal.timeout(10000),
|
||||
filters: [{kinds: [RELAY_INVITE]}],
|
||||
}),
|
||||
sleep(2000),
|
||||
])
|
||||
|
||||
claim = getTagValue("claim", event?.tags || []) || ""
|
||||
loading = false
|
||||
claim = getTagValue("claim", event?.tags || []) || ""
|
||||
|
priyanshu_bharti marked this conversation as resolved
Outdated
|
||||
} catch {
|
||||
claim = ""
|
||||
} finally {
|
||||
loading = false
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user
Do we need this? The timeout signal should abort the request with no events, which means the claim would be set to an empty string in any case. I think this is over-complicating it and increasing the timeout to 10s would be sufficient
Youre right , i removed the extra timeout race and left the request abort signal to handle the timeout. Thanks for the feedback