From ba8bb1da59b425a34b394dbc20c8ffbf376c8141 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Wed, 5 Nov 2025 07:05:20 +0000 Subject: [PATCH] completionId: cgen-ab34dee1a9274bd1b034bdc8fe38c2de cgen-ab34dee1a9274bd1b034bdc8fe38c2de --- client/pages/Feed.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/client/pages/Feed.tsx b/client/pages/Feed.tsx index e2577d60..96dd5096 100644 --- a/client/pages/Feed.tsx +++ b/client/pages/Feed.tsx @@ -112,11 +112,20 @@ export default function Feed() { const fetchFeed = useCallback(async () => { setIsLoading(true); try { - // Parallelize posts and following fetch + // Add timeout to prevent hanging indefinitely + const withTimeout = (promise: Promise, ms: number): Promise => + Promise.race([ + promise, + new Promise((_, reject) => + setTimeout(() => reject(new Error("Request timeout")), ms) + ), + ]); + + // Parallelize posts and following fetch with 10s timeout const [posts, flw] = await Promise.all([ - communityService.getPosts(30), + withTimeout(communityService.getPosts(30), 10000), user?.id - ? aethexSocialService.getFollowing(user.id) + ? withTimeout(aethexSocialService.getFollowing(user.id), 10000) : Promise.resolve([]), ]);