Fix #202 slow-network invite timeout handling #207

Merged
hodlbod merged 2 commits from priyanshu_bharti/flotilla:fix/issue-202-slow-network-invite-timeout into dev 2026-04-15 22:01:01 +00:00
+16 -14
View File
@@ -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
Outdated
Review

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

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
Outdated
Review

Youre right , i removed the extra timeout race and left the request abort signal to handle the timeout. Thanks for the feedback

Youre right , i removed the extra timeout race and left the request abort signal to handle the timeout. Thanks for the feedback
} catch {
claim = ""
} finally {
loading = false
}
})
</script>