From 805639dba4fafd1d45020d7e33912e2d99d47b3a Mon Sep 17 00:00:00 2001 From: UrNas Date: Wed, 21 Jun 2023 02:01:22 +0300 Subject: [PATCH] check chats length before run kv.pipeline() otherwise get empty pipeline --- app/actions.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/actions.ts b/app/actions.ts index 90c6973..2c8a5dd 100644 --- a/app/actions.ts +++ b/app/actions.ts @@ -74,7 +74,9 @@ export async function clearChats() { } const chats: string[] = await kv.zrange(`user:chat:${session.user.id}`, 0, -1) - + if (!chats.length) { + return redirect('/') + } const pipeline = kv.pipeline() for (const chat of chats) {