completionId: cgen-0e31190aaa9247d69a7ad9bebc4a8e12

cgen-0e31190aaa9247d69a7ad9bebc4a8e12
This commit is contained in:
Builder.io 2025-11-05 07:11:17 +00:00
parent 26b7d90da4
commit f82a56e2ca

View file

@ -112,20 +112,11 @@ export default function Feed() {
const fetchFeed = useCallback(async () => {
setIsLoading(true);
try {
// Add timeout to prevent hanging indefinitely
const withTimeout = <T,>(promise: Promise<T>, ms: number): Promise<T> =>
Promise.race([
promise,
new Promise<T>((_, reject) =>
setTimeout(() => reject(new Error("Request timeout")), ms)
),
]);
// Parallelize posts and following fetch with 10s timeout
// Parallelize posts and following fetch
const [posts, flw] = await Promise.all([
withTimeout(communityService.getPosts(30), 10000),
communityService.getPosts(30),
user?.id
? withTimeout(aethexSocialService.getFollowing(user.id), 10000)
? aethexSocialService.getFollowing(user.id)
: Promise.resolve([]),
]);