From e7a0add8cc0e8c0c1412eeb2037326d25e8dd406 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Tue, 26 Aug 2025 11:01:31 -0700 Subject: [PATCH] Throw some errors on invalid relay urls --- packages/app/src/relays.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/app/src/relays.ts b/packages/app/src/relays.ts index a4ad2b9..90aa519 100644 --- a/packages/app/src/relays.ts +++ b/packages/app/src/relays.ts @@ -119,6 +119,11 @@ export const { const relay = stale.get(url) const profile = fresh.get(url) + if (!url || !isRelayUrl(url)) { + console.warn(`Attempted to load invalid relay url: ${url}`) + continue + } + if (profile) { stale.set(url, {...relay, profile, url}) } @@ -176,6 +181,11 @@ const updateRelayStats = batch(500, (updates: RelayStatsUpdate[]) => { for (const [url, items] of $itemsByUrl.entries()) { const $relay: Relay = $relaysByUrl.get(url) || {url} + if (!url || !isRelayUrl(url)) { + console.warn(`Attempted to update stats for an invalid relay url: ${url}`) + continue + } + if (!$relay.stats) { $relay.stats = makeRelayStats() } else if ($relay.stats.notice_count === undefined) {