Fix: Prevent getAgents Server Action from throwing to avoid Next.js Server Component render crashes
This commit is contained in:
1 parent
2be8b08074
commit
0d4802f14a
1 file changed
+3
-3
@@ -44,7 +44,7 @@ export async function getAgents(clientSiteUuid?: string): Promise<Agent[]> {
|
||||
}
|
||||
} catch (connErr: any) {
|
||||
console.error("[getAgents Action] Connection failed:", connErr.message);
|
||||
throw connErr;
|
||||
return []; // Do not throw to avoid Next.js Server Component crash
|
||||
}
|
||||
const db = mongoose.connection.db;
|
||||
|
||||
@@ -71,8 +71,8 @@ export async function getAgents(clientSiteUuid?: string): Promise<Agent[]> {
|
||||
|
||||
return result.data || [];
|
||||
} catch (error: any) {
|
||||
console.error("Error fetching agents:", error);
|
||||
throw new Error(error.message || "Failed to retrieve agents inventory.");
|
||||
console.error("[getAgents Action] Error fetching agents:", error);
|
||||
return []; // Do not throw to avoid Next.js Server Component crash
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user