diff --git a/app/lib/dbConnect.ts b/app/lib/dbConnect.ts index 6e3b67d..4e108c8 100644 --- a/app/lib/dbConnect.ts +++ b/app/lib/dbConnect.ts @@ -66,10 +66,12 @@ async function dbConnect(uri?: string, retries = 3): Promise { const opts = { bufferCommands: false, maxPoolSize: 10, - minPoolSize: 2, - serverSelectionTimeoutMS: 5000, - socketTimeoutMS: 45000, + minPoolSize: 1, + serverSelectionTimeoutMS: 10000, + socketTimeoutMS: 20000, connectTimeoutMS: 10000, + maxIdleTimeMS: 30000, + waitQueueTimeoutMS: 5000, }; cached.promise = mongoose diff --git a/app/posts/[slug]/error.tsx b/app/posts/[slug]/error.tsx new file mode 100644 index 0000000..5aefa88 --- /dev/null +++ b/app/posts/[slug]/error.tsx @@ -0,0 +1,50 @@ +'use client'; + +import Link from 'next/link'; +import { useEffect } from 'react'; + +export default function Error({ + error, + reset, +}: { + error: Error & { digest?: string }; + reset: () => void; +}) { + useEffect(() => { + console.error('Post detail error:', error); + }, [error]); + + return ( +
+
+

+ 글을 불러오는데 실패했습니다 +

+

+ {error.message === 'Post not found' + ? '요청하신 글을 찾을 수 없습니다.' + : '일시적인 오류가 발생했습니다. 잠시 후 다시 시도해주세요.'} +

+
+ + + 목록으로 + +
+ {error.digest && ( +

+ 오류 ID: {error.digest} +

+ )} +
+
+ ); +} diff --git a/app/posts/[slug]/loading.tsx b/app/posts/[slug]/loading.tsx new file mode 100644 index 0000000..8193b36 --- /dev/null +++ b/app/posts/[slug]/loading.tsx @@ -0,0 +1,12 @@ +import SVGLoadingSpinner from '@/app/entities/common/Loading/SVGLoadingSpinner'; + +export default function Loading() { + return ( +
+ +

+ 글을 불러오는 중... +

+
+ ); +} diff --git a/app/posts/[slug]/page.tsx b/app/posts/[slug]/page.tsx index a135b2b..96f2944 100644 --- a/app/posts/[slug]/page.tsx +++ b/app/posts/[slug]/page.tsx @@ -21,7 +21,7 @@ export async function generateStaticParams() { } // ISR 활성화하기 -export const revalidate = 60; // 60초마다 재검증 +export const revalidate = 300; // 300초(5분)마다 재검증 async function getPostDetail(slug: string) { await dbConnect(); @@ -60,7 +60,7 @@ export const generateMetadata = async ({ authors: [post.author], }, other: { - 'application-name': 'Shipfriend Tech Blog', + 'application-name': 'ShipFriend TechBlog', author: post.author, publish_date: new Date(post.date).toISOString(), 'og:type': 'article', diff --git a/app/posts/layout.tsx b/app/posts/layout.tsx index 16137b0..fcb9de5 100644 --- a/app/posts/layout.tsx +++ b/app/posts/layout.tsx @@ -1,11 +1,11 @@ import { Suspense } from 'react'; -import SVGLoadingSpinner from '@/app/entities/common/Loading/SVGLoadingSpinner'; +import Loading from './[slug]/loading'; interface LayoutProps { children: React.ReactNode; } const Layout = ({ children }: LayoutProps) => { - return }>{children}; + return }>{children}; }; export default Layout;