From 1db004b25958420976c4c5c9bc34091fde1a1888 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Mon, 10 Nov 2025 03:06:24 +0000 Subject: [PATCH] completionId: cgen-bfa502fa2cc04e66b20493388085f512 cgen-bfa502fa2cc04e66b20493388085f512 --- client/contexts/AuthContext.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/client/contexts/AuthContext.tsx b/client/contexts/AuthContext.tsx index c863323d..ba974a8c 100644 --- a/client/contexts/AuthContext.tsx +++ b/client/contexts/AuthContext.tsx @@ -318,8 +318,19 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ userId: string, ): Promise => { try { - // Fetch user profile - let errors happen naturally rather than with aggressive timeouts - const userProfile = await aethexUserService.getCurrentUser(); + // Fetch user profile with a 3-second timeout to prevent hanging + const profilePromise = aethexUserService.getCurrentUser(); + const timeoutPromise = new Promise((resolve) => + setTimeout(() => resolve(null), 3000) + ); + const userProfile = await Promise.race([profilePromise, timeoutPromise]); + + if (!userProfile) { + console.warn("Profile fetch timed out or returned null"); + setProfile(null); + return null; + } + setProfile(userProfile); // Fetch roles in parallel (non-blocking) - don't await here