Fix revalidatePath during render in getDefaultDashboardSlug
On a new user's first load, getDefaultDashboardSlug fell through to
createDashboard("Home"), which calls revalidatePath("/"). That is illegal
in a render context (page component → server action → revalidatePath).
Inline the DB insert directly in the fallback and skip revalidatePath —
the redirect that immediately follows is a fresh request, so no cache
invalidation is needed here.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
484f747f66
commit
2129f9718f
@@ -50,9 +50,13 @@ export async function getDefaultDashboardSlug(): Promise<string> {
|
||||
.orderBy(asc(dashboards.position), asc(dashboards.createdAt))
|
||||
.limit(1);
|
||||
if (first) return first.slug;
|
||||
// No dashboards yet — create Home
|
||||
await createDashboard("Home");
|
||||
return "home";
|
||||
// No dashboards yet — insert one directly without revalidatePath (we're in a
|
||||
// render path; the redirect that follows is a fresh request anyway).
|
||||
const slug = await uniqueSlug(user.id, "home");
|
||||
await db
|
||||
.insert(dashboards)
|
||||
.values({ userId: user.id, name: "Home", slug, isDefault: false, position: 0 });
|
||||
return slug;
|
||||
}
|
||||
|
||||
export async function getDashboardBySlug(slug: string) {
|
||||
|
||||
Reference in New Issue
Block a user