completionId: cgen-a688056a498840bdb1931a7a8c445a1b
cgen-a688056a498840bdb1931a7a8c445a1b
This commit is contained in:
parent
19f334de8a
commit
9f8a4dfd98
1 changed files with 15 additions and 4 deletions
|
|
@ -29,10 +29,21 @@ export const aethexSocialService = {
|
||||||
|
|
||||||
async getFollowing(userId: string): Promise<string[]> {
|
async getFollowing(userId: string): Promise<string[]> {
|
||||||
try {
|
try {
|
||||||
const { data, error } = await supabase
|
// Add timeout to prevent hanging
|
||||||
.from("user_follows")
|
const controller = new AbortController();
|
||||||
.select("following_id")
|
const timeoutId = setTimeout(() => controller.abort(), 8000);
|
||||||
.eq("follower_id", userId);
|
|
||||||
|
const { data, error } = await Promise.race([
|
||||||
|
supabase
|
||||||
|
.from("user_follows")
|
||||||
|
.select("following_id")
|
||||||
|
.eq("follower_id", userId),
|
||||||
|
new Promise<any>((_, reject) =>
|
||||||
|
setTimeout(() => reject(new Error("getFollowing timeout")), 7900),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error(
|
console.error(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue