nextjs
resource_error
ai_generated
partial
Error: Static generation timed out after 60 seconds for path '/[slug]'. Consider increasing the static generation timeout or reducing the number of static paths.
ID: nextjs/static-generation-buffer-timeout
80%Fix Rate
86%Confidence
1Evidence
2023-08-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 13.4.0 | active | — | — | — |
| 13.5.0 | active | — | — | — |
| 14.0.0 | active | — | — | — |
| 14.1.0 | active | — | — | — |
| 14.2.0 | active | — | — | — |
| 15.0.0 | active | — | — | — |
Root Cause
Next.js has a default 60-second timeout for generating static pages during build. If generateStaticParams returns many paths or the page component has slow data fetching, the build may exceed this limit.
generic中文
Next.js 在构建期间对生成静态页面有默认的 60 秒超时。如果 generateStaticParams 返回许多路径或页面组件有慢速数据获取,构建可能会超过此限制。
Official Documentation
https://nextjs.org/docs/messages/static-generation-timeoutWorkarounds
-
85% success Increase the static generation timeout in next.config.js: module.exports = { staticPageGenerationTimeout: 120 }; (value in seconds). This gives more time for complex builds.
Increase the static generation timeout in next.config.js: module.exports = { staticPageGenerationTimeout: 120 }; (value in seconds). This gives more time for complex builds. -
80% success Optimize generateStaticParams by batching API calls, implementing caching, or using incremental static regeneration (ISR) with revalidate option to reduce the number of paths generated at build time. Example: export async function generateStaticParams() { const slugs = await fetch('/api/slugs?limit=100'); return slugs.map(s => ({ slug: s })); }
Optimize generateStaticParams by batching API calls, implementing caching, or using incremental static regeneration (ISR) with revalidate option to reduce the number of paths generated at build time. Example: export async function generateStaticParams() { const slugs = await fetch('/api/slugs?limit=100'); return slugs.map(s => ({ slug: s })); } -
75% success Use dynamicParams: false in the page component to ensure only explicitly returned paths are pre-rendered, and fall back to dynamic rendering for others.
Use dynamicParams: false in the page component to ensure only explicitly returned paths are pre-rendered, and fall back to dynamic rendering for others.
中文步骤
Increase the static generation timeout in next.config.js: module.exports = { staticPageGenerationTimeout: 120 }; (value in seconds). This gives more time for complex builds.Optimize generateStaticParams by batching API calls, implementing caching, or using incremental static regeneration (ISR) with revalidate option to reduce the number of paths generated at build time. Example: export async function generateStaticParams() { const slugs = await fetch('/api/slugs?limit=100'); return slugs.map(s => ({ slug: s })); }Use dynamicParams: false in the page component to ensure only explicitly returned paths are pre-rendered, and fall back to dynamic rendering for others.
Dead Ends
Common approaches that don't work:
-
Setting generateStaticParams to return an empty array to avoid the timeout
20% fail
This defeats the purpose of static generation; all pages will be dynamically rendered at request time, losing performance benefits.
-
Adding console.log statements inside generateStaticParams to debug, which adds overhead and makes the timeout worse
50% fail
Logging increases I/O and slows down the generation process, potentially causing more timeouts.