From ba9b4fc4ea4f8e4c675ad68cebd50393e9802ccc Mon Sep 17 00:00:00 2001 From: Jez Date: Sat, 8 Nov 2025 15:12:49 +1100 Subject: [PATCH] fix: add NEXT_REDIRECT error handling to update todo action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add proper handling for Next.js redirect errors in updateTodoAction to match the pattern used in createTodoAction. Without this, redirect() calls from server actions could be incorrectly logged as errors. Changes: - Check if error message is 'NEXT_REDIRECT' before error logging - Re-throw NEXT_REDIRECT errors unchanged to allow proper redirection - Prevents false error logs in console for successful operations This matches the existing pattern in create-todo.action.ts for consistency. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/modules/todos/actions/update-todo.action.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/todos/actions/update-todo.action.ts b/src/modules/todos/actions/update-todo.action.ts index 99e4c6a..bbdf1d4 100644 --- a/src/modules/todos/actions/update-todo.action.ts +++ b/src/modules/todos/actions/update-todo.action.ts @@ -86,6 +86,11 @@ export async function updateTodoAction(todoId: number, formData: FormData) { revalidatePath(todosRoutes.list); redirect(todosRoutes.list); } catch (error) { + // Handle Next.js redirect errors - these are not actual errors + if (error instanceof Error && error.message === "NEXT_REDIRECT") { + throw error; // Re-throw redirect errors as-is + } + console.error("Error updating todo:", error); if (