diff --git a/snapshot/src/cli.ts b/snapshot/src/cli.ts index b44b346..dbd629e 100644 --- a/snapshot/src/cli.ts +++ b/snapshot/src/cli.ts @@ -92,12 +92,17 @@ async function main(): Promise { posts: postJsons, }) - const allDeletedCoords = deletions.flatMap((d) => + const currentDeletedCoords = deletions.flatMap((d) => d.tags.filter((t) => t[0] === 'a' && t[1]).map((t) => t[1] as string) ) + // Cache akkumuliert deletedCoords ueber alle bisherigen runs — nicht + // ersetzen: wenn ein relay beim naechsten run die alten kind:5-events + // nicht mehr liefert (GC, relay-tausch), wuerde sonst der vergleich + // gegen previousDeletedCoords im naechsten lauf wieder als "neu" + // werten und einen false-positive hard-fail ausloesen. const newCache: CacheState = { lastKnownGoodCount: filtered.length, - deletedCoords: [...new Set(allDeletedCoords)], + deletedCoords: [...new Set([...(cache?.deletedCoords ?? []), ...currentDeletedCoords])], } await writeCache(cachePath, newCache) diff --git a/snapshot/src/core/relays.ts b/snapshot/src/core/relays.ts index 348010d..7510690 100644 --- a/snapshot/src/core/relays.ts +++ b/snapshot/src/core/relays.ts @@ -70,6 +70,11 @@ export const defaultEventFetcher: EventFetcher = async (relay, pubkey) => { error: () => resolve(out), complete: () => resolve(out), }) + // Belt-and-suspenders: falls subscribe-callback weder error noch + // complete feuert (z.B. timeout-operator wird intern verschluckt), + // schliessen wir nach timeout+1s manuell. Resolve() kommt dann nicht + // mehr durch (Promise schon settled), aber der Relay-Handle wird + // entsorgt — kein leak. setTimeout(() => sub.unsubscribe(), 11_000) }) }