From 1bc80e190fee7fb5ad6ce0d2ba15128c5132a409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Ben=C3=ADtez?= Date: Thu, 28 May 2026 00:43:28 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20timeout=2010s=20en=20AuthProvider=20?= =?UTF-8?q?=E2=80=94=20spinner=20no=20queda=20bloqueado=20si=20Supabase=20?= =?UTF-8?q?no=20responde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- src/auth/AuthContext.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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(), [])