feat: add background retry scheduler for federation password sync
Replace the give-up-after-3-retries path with a persistent background scheduler: 10 retries every 30s (5 min), then 12 retries every 5 min (1 hr). Active timers are keyed by origin so rapid password changes cancel and replace the previous loop. All timers are cleared on logout via clearPasswordSyncTimers() called from instanceStore.reset().
This commit is contained in:
@@ -5,6 +5,10 @@ import { useAuthStore } from './authStore';
|
||||
import { setApiForOriginResolver, setUserIdForOriginResolver, setOriginFromHostnameResolver, useSpaceStore } from './spaceStore';
|
||||
import { connectInstance, disconnectInstance, disconnectAllRemote } from '../hooks/useWebSocket';
|
||||
import { syncProfileToRemote } from '../utils/profileSync';
|
||||
// Circular dependency: federationOps imports useInstanceStore, instanceStore imports this.
|
||||
// Safe because both modules access each other lazily (at call time, not import time).
|
||||
// clearPasswordSyncTimers itself does not reference useInstanceStore.
|
||||
import { clearPasswordSyncTimers } from '../utils/federationOps';
|
||||
|
||||
// ─── Types ───────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -696,6 +700,8 @@ export const useInstanceStore = create<InstanceState>((set, get) => ({
|
||||
// Tear down all remote WebSocket connections
|
||||
disconnectAllRemote();
|
||||
|
||||
clearPasswordSyncTimers();
|
||||
|
||||
set({ instances: [], isLoading: false, error: null, _autoConnectDone: false, pendingSyncOrigins: [] });
|
||||
// Token cache preserved — scoped per user, survives logout for seamless reconnect
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user