Fix discovered relays cache invalidation: add version suffix to cache key so servingNames data is rebuilt after code change

This commit is contained in:
Laan Tungir
2026-06-26 21:33:34 -04:00
parent e734f33542
commit 8c456ec522
2 changed files with 7 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
{
"VERSION": "v0.7.53",
"VERSION_NUMBER": "0.7.53",
"BUILD_DATE": "2026-06-27T00:20:37.017Z"
"VERSION": "v0.7.54",
"VERSION_NUMBER": "0.7.54",
"BUILD_DATE": "2026-06-27T01:33:34.109Z"
}

View File

@@ -6449,8 +6449,11 @@ function shortHexPubkey(hex) {
}
// Cache for discovered relays — rebuilt only when the contact list changes.
// The version suffix forces a rebuild when the handler code changes (e.g.
// adding servingNames).
let discoveredRelaysCache = null;
let discoveredRelaysCacheKey = '';
const DISCOVERED_RELAYS_CACHE_VERSION = 'v2-names';
async function handleGetDiscoveredRelays(requestId, port) {
try {
@@ -6478,7 +6481,7 @@ async function handleGetDiscoveredRelays(requestId, port) {
? Array.from(kind3Events).sort((a, b) => (b.created_at || 0) - (a.created_at || 0))[0]
: null;
const followedPubkeys = latestKind3 ? extractFollowedPubkeysFromKind3(latestKind3) : [];
const cacheKey = `${latestKind3?.id || 'none'}_${latestKind3?.created_at || 0}`;
const cacheKey = `${DISCOVERED_RELAYS_CACHE_VERSION}_${latestKind3?.id || 'none'}_${latestKind3?.created_at || 0}`;
// Rebuild the relay→[pubkeys] mapping from follows' kind 10002 events
// in the Dexie cache if the contact list has changed.