From 0d4802f14a47251e0e25b656f80c5e0198231a83 Mon Sep 17 00:00:00 2001 From: ypratama Date: Fri, 28 Aug 2026 16:59:18 +0700 Subject: [PATCH] Fix: Prevent getAgents Server Action from throwing to avoid Next.js Server Component render crashes --- src/lib/actions/agents.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/actions/agents.ts b/src/lib/actions/agents.ts index 08ed7f0..05d4f76 100644 --- a/src/lib/actions/agents.ts +++ b/src/lib/actions/agents.ts @@ -44,7 +44,7 @@ export async function getAgents(clientSiteUuid?: string): Promise { } } 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 { 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 } }