nextjs
build_error
ai_generated
partial
Error: Static generation timed out after 60 seconds for path '/[slug]'. Consider increasing the static generation timeout or using dynamic rendering.
ID: nextjs/static-generation-timeout-generatestaticparams
87%Fix Rate
84%Confidence
1Evidence
2024-07-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Next.js 14.2.5 | active | — | — | — |
| Next.js 13.5.0 | active | — | — | — |
Root Cause
The generateStaticParams function or the page rendering for a dynamic route took longer than the default 60-second timeout during static generation, often due to slow data fetching or excessive number of paths.
generic中文
在静态生成期间,generateStaticParams 函数或动态路由的页面渲染耗时超过默认的 60 秒超时,通常是由于数据获取缓慢或路径过多。
Official Documentation
https://nextjs.org/docs/messages/static-generation-timeoutWorkarounds
-
85% success Optimize generateStaticParams by caching API calls: const paths = await fetch('/api/paths', { next: { revalidate: 3600 } })
Optimize generateStaticParams by caching API calls: const paths = await fetch('/api/paths', { next: { revalidate: 3600 } }) -
90% success Use incremental static regeneration (ISR) with revalidate instead of full static generation: export const revalidate = 3600
Use incremental static regeneration (ISR) with revalidate instead of full static generation: export const revalidate = 3600
-
95% success Switch to dynamic rendering for this page by removing generateStaticParams or adding export const dynamic = 'force-dynamic'
Switch to dynamic rendering for this page by removing generateStaticParams or adding export const dynamic = 'force-dynamic'
中文步骤
Optimize generateStaticParams by caching API calls: const paths = await fetch('/api/paths', { next: { revalidate: 3600 } })Use incremental static regeneration (ISR) with revalidate instead of full static generation: export const revalidate = 3600
Switch to dynamic rendering for this page by removing generateStaticParams or adding export const dynamic = 'force-dynamic'
Dead Ends
Common approaches that don't work:
-
50% fail
This only masks the problem; if the underlying data fetch is slow, it may still timeout at higher limits.
-
70% fail
This breaks the dynamic routing functionality and may not be feasible for content-driven sites.