Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor: dedupe useAutoRefetch's fetch-error normalization into one helper
[._.]/ Adam Eivyfe76308a6998
diff --git a/client/src/hooks/useAutoRefetch.js b/client/src/hooks/useAutoRefetch.jsindex f8f91b08e9..4fe6395596 100644--- a/client/src/hooks/useAutoRefetch.js+++ b/client/src/hooks/useAutoRefetch.js@@ -47,6 +47,11 @@ import { useVisibilityEvent } from './useVisibilityEvent.js';* erasing the last good render checks `error` alongside `data` rather than* inferring staleness from an empty/falsy `data`.*/+// Normalize whatever a rejected fetchFn threw (an Error, or any other value —+// a caller can reject with a plain string/object) into a real Error so+// `error.message` is always safe to read.+const toFetchError = (err) => (err instanceof Error ? err : new Error(String(err ?? 'Auto-refetch failed')));+export function useAutoRefetch(fetchFn, intervalMs, options = {}) {const { enabled = true, immediate = true, compare, pollOnly = false } = options;const [data, setData] = useState(null);@@ -89,7 +94,7 @@ export function useAutoRefetch(fetchFn, intervalMs, options = {}) {console.warn(`⚠️ Auto-refetch failed: ${err?.message ?? String(err)}`);if (!pollOnly) {setLoading(false);- setError(err instanceof Error ? err : new Error(String(err ?? 'Auto-refetch failed')));+ setError(toFetchError(err));}return undefined;}@@ -116,7 +121,7 @@ export function useAutoRefetch(fetchFn, intervalMs, options = {}) {console.warn(`⚠️ Auto-refetch failed: ${err?.message ?? String(err)}`);if (!cancelled && !pollOnly) {setLoading(false);- setError(err instanceof Error ? err : new Error(String(err ?? 'Auto-refetch failed')));+ setError(toFetchError(err));}}};