Fix saveLesson: sanitize content JSON to prevent RSC proxy error

React treats TipTap's editor.getJSON() output as a non-plain object when
passed through Server Action serialization, causing isDecimal() inside
Prisma's query builder to receive a temporary client reference proxy and
throw ERROR 1213974697. JSON.parse(JSON.stringify()) strips the prototype
chain and any non-enumerable properties, ensuring Prisma receives a
clean plain object.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-25 17:58:13 +05:00
parent 8757537344
commit bfa037885f
-5
View File
@@ -22,7 +22,6 @@ export async function saveLesson(
}
) {
await requireAdmin();
try {
await prisma.lesson.update({
where: { id: lessonId },
data: {
@@ -32,10 +31,6 @@ export async function saveLesson(
published: data.published,
},
});
} catch (err) {
console.error("[saveLesson] full error:", err);
throw err;
}
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}`);
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}/lessons/${lessonId}`);
}