diff --git a/src/auth/AuthContext.tsx b/src/auth/AuthContext.tsx index 32864e7..f023489 100644 --- a/src/auth/AuthContext.tsx +++ b/src/auth/AuthContext.tsx @@ -18,11 +18,24 @@ export function AuthProvider({ children }: { children: ReactNode }) { const [loading, setLoading] = useState(true) useEffect(() => { + // Timeout de seguridad: si Supabase no responde en 10s, desbloquear UI + const timeout = setTimeout(() => { + setLoading((prev) => { + if (prev) console.error('Auth timeout: la sesión de Supabase no respondió en 10s') + return false + }) + }, 10_000) + const unsubscribe = authService.onAuthStateChange((u) => { + clearTimeout(timeout) setUser(u) setLoading(false) }) - return unsubscribe + + return () => { + clearTimeout(timeout) + unsubscribe() + } }, []) const signIn = useCallback(() => authService.signInWithGoogle(), [])