mirror of
https://github.com/hoornet/vega.git
synced 2026-05-09 05:39:10 -07:00
Fix relay connectivity: remove aggressive liveness probe, add fetch timeouts
The liveness probe in ensureConnected was causing a death spiral — it force-disconnected working relays when a 3s probe timed out, then resetNDK killed new connections before they could establish. Now ensureConnected trusts relay.connected and only reconnects when zero relays are connected. All fetchEvents calls have timeouts (5-10s) so nothing hangs. resetNDK kept as background-only recovery in the connection monitor after 30s of continuous failure. Also adds feed diagnostics (feedDiagnostics.ts) for tracking fetch timing, event freshness, and relay states via console helpers.
This commit is contained in:
@@ -3,7 +3,8 @@ import { useFeedStore } from "../../stores/feed";
|
||||
import { useUserStore } from "../../stores/user";
|
||||
import { useMuteStore } from "../../stores/mute";
|
||||
import { useUIStore } from "../../stores/ui";
|
||||
import { fetchFollowFeed, getNDK } from "../../lib/nostr";
|
||||
import { fetchFollowFeed, getNDK, ensureConnected } from "../../lib/nostr";
|
||||
import { diagWrapFetch, logDiag } from "../../lib/feedDiagnostics";
|
||||
import { detectScript, getEventLanguageTag, FILTER_SCRIPTS } from "../../lib/language";
|
||||
import { NoteCard } from "./NoteCard";
|
||||
import { ArticleCard } from "../article/ArticleCard";
|
||||
@@ -38,7 +39,8 @@ export function Feed() {
|
||||
const loadFollowFeed = async () => {
|
||||
setFollowLoading(true);
|
||||
try {
|
||||
const events = await fetchFollowFeed(follows);
|
||||
await ensureConnected();
|
||||
const events = await diagWrapFetch("follow_fetch", () => fetchFollowFeed(follows));
|
||||
setFollowNotes(events);
|
||||
} finally {
|
||||
setFollowLoading(false);
|
||||
@@ -140,7 +142,10 @@ export function Feed() {
|
||||
</span>
|
||||
)}
|
||||
<button
|
||||
onClick={isTrending ? () => loadTrendingFeed(true) : isFollowing ? loadFollowFeed : loadFeed}
|
||||
onClick={() => {
|
||||
logDiag({ ts: new Date().toISOString(), action: "refresh_click", details: `tab=${tab}` });
|
||||
(isTrending ? () => loadTrendingFeed(true) : isFollowing ? loadFollowFeed : loadFeed)();
|
||||
}}
|
||||
disabled={isLoading}
|
||||
className="text-text-muted hover:text-text text-[11px] px-2 py-1 border border-border hover:border-text-dim transition-colors disabled:opacity-40"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user