Calendar event naddr links fail to resolve on direct load — relay hints stripped and config not initialized #3
Labels
No labels
bug
discussion
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
edufeed/edufeed-app#3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Report
This link does not resolve on prod:
https://edufeed.org/calendar/event/naddr1qvzqqqrukvpzqna968zp8c45tcgdgzln2c4twqd9xvfqdc6eey964c8fn07kcmjpqqjxzwpex5ukydrp95ekxepc956r2e3e95unvc3k95mn2wrpxyerzvpnxycxv252m6y
while the same naddr resolves on dev:
https://dev.edufeed.org/calendar/event/naddr1qvzqqqrukvpzqna968zp8c45tcgdgzln2c4twqd9xvfqdc6eey964c8fn07kcmjpqqjxzwpex5ukydrp95ekxepc956r2e3e95unvc3k95mn2wrpxyerzvpnxycxv252m6y
Decoding the naddr shows
relays: []— no relay hints embedded. Whether it resolves then depends entirely on the deployment's configured relays, which explains the prod/dev difference.Root cause analysis (confirmed in code)
Three compounding defects:
/calendar/event/[naddr]never initializes the runtime config.src/routes/calendar/event/[naddr]/+page.jscallsfetchEventById()directly. The root/[naddr]route (src/routes/[naddr=naddr]/+page.js:18-21) explicitly awaitsparent()and callsinitializeConfig()first — the calendar route does not. On a cold/direct page load the config is still empty, sogetAllLookupRelays()returns[]and a hint-less naddr cannot resolve.The canonical redirect strips relay hints. The share/copy link points at the root route and does embed relay hints (
encodeEventBech32→encodeEventToNaddrwith seen-relays). But the root route canonically redirects calendar events to/calendar/event/<naddr>viagetCanonicalEventRoute(), andsrc/lib/helpers/eventRouteRedirect.js:77re-encodes withrelays: []. The browser address bar therefore always ends up showing the fragile hint-less URL — which is exactly what users copy.No staged fallback.
fetchEventById(src/lib/helpers/nostrUtils.js:210-250) makes a singleaddressLoadercall with one relay list and gives up after 8 s. There is no "hints failed → configured relays → indexer relays" escalation.Fix plan
eventRouteRedirect.js)fetchEventByIdFix implemented and verified on branch
fix/issue-3-naddr-resolution(2 commits, based ondev).Changes:
/calendar/event/[naddr]load now initializes the runtime config before fetching (same pattern as the root/[naddr]route), so lookup relays are available on cold/direct loads.fetchEventByIdunions naddr relay hints with the configured lookup relays instead of using hints exclusively (mirrors the existing nevent path).getCanonicalEventRoutere-encodes naddrs with relay hints: seen-relays first, falling back to the hints carried by the incoming naddr (important for cache-served events). The root route passes those inbound hints through the canonical redirect.Verification (local dev server, empty client cache):
/<naddr-with-hints>now redirects to a/calendar/event/<naddr>URL whose naddr decodes with relayswss://relay-rpi.edufeed.org,wss://relay.edufeed.org— the copied browser URL stays resolvable on any deployment.Covered by new unit tests (route load config-init, relay union, redirect hint preservation).
Note: the prod/dev difference was config/code drift between deployments — with hint-less naddrs, resolution depended entirely on which relays the deployment queries. After merge+deploy the reported link will still be hint-less, but will resolve via lookup relays, and newly copied links will carry hints.
Confirmed by Steffen (cold-load resolution + relay hints in the address bar). Merged to dev.