From 2e5563fe5924e1b75368d5d4e200361f1c167c97 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 8 Nov 2025 09:14:58 +0000 Subject: [PATCH] Force loading to false after timeout, regardless of fetchUserProfile state cgen-fc94b84d308e41afbb64105f43788e13 --- client/contexts/AuthContext.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/contexts/AuthContext.tsx b/client/contexts/AuthContext.tsx index 6890dd07..d9728dfa 100644 --- a/client/contexts/AuthContext.tsx +++ b/client/contexts/AuthContext.tsx @@ -339,11 +339,17 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ }); // Don't wait for rolesPromise - continue immediately - setLoading(false); + // Always set loading to false, even if role fetching hasn't completed + setTimeout(() => { + setLoading(false); + }, 100); return userProfile; } catch (error) { console.error("Error fetching user profile:", error); - setLoading(false); + // Always set loading to false even on error + setTimeout(() => { + setLoading(false); + }, 100); return null; } };