diff --git a/src/app/actions/books.ts b/src/app/actions/books.ts index 1174e52..ed6303c 100644 --- a/src/app/actions/books.ts +++ b/src/app/actions/books.ts @@ -3,6 +3,7 @@ import { BookService } from "@/lib/services/book.service"; import { AppError } from "@/utils/errors"; import type { KomgaBook } from "@/types/komga"; +import logger from "@/lib/logger"; interface BookDataResult { success: boolean; @@ -17,7 +18,12 @@ interface BookDataResult { export async function getBookData(bookId: string): Promise { try { const data = await BookService.getBook(bookId); - const nextBook = await BookService.getNextBook(bookId, data.book.seriesId); + let nextBook = null; + try { + nextBook = await BookService.getNextBook(bookId, data.book.seriesId); + } catch (error) { + logger.warn({ err: error, bookId }, "Failed to fetch next book in server action"); + } return { success: true, diff --git a/src/app/books/[bookId]/page.tsx b/src/app/books/[bookId]/page.tsx index 7511c0d..7a806db 100644 --- a/src/app/books/[bookId]/page.tsx +++ b/src/app/books/[bookId]/page.tsx @@ -5,6 +5,7 @@ import { BookService } from "@/lib/services/book.service"; import { ERROR_CODES } from "@/constants/errorCodes"; import { AppError } from "@/utils/errors"; import { redirect } from "next/navigation"; +import logger from "@/lib/logger"; export default async function BookPage({ params }: { params: Promise<{ bookId: string }> }) { const { bookId } = await params; @@ -12,7 +13,12 @@ export default async function BookPage({ params }: { params: Promise<{ bookId: s try { // SSR: Fetch directly on server instead of client-side XHR const data = await BookService.getBook(bookId); - const nextBook = await BookService.getNextBook(bookId, data.book.seriesId); + let nextBook = null; + try { + nextBook = await BookService.getNextBook(bookId, data.book.seriesId); + } catch (error) { + logger.warn({ err: error, bookId }, "Failed to fetch next book, continuing without it"); + } return ( }>