错误:路径 '/[slug]' 的静态生成在 60 秒后超时。考虑增加静态生成超时时间。
Error: Static generation timed out after 60 seconds for path '/[slug]'. Consider increasing the static generation timeout.
ID: nextjs/static-generation-timeout-slug
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Next.js 13.3+ | active | — | — | — |
| Next.js 14.0 | active | — | — | — |
| Next.js 15.0 | active | — | — | — |
根因分析
在静态生成期间(例如,使用 `output: export` 或 `generateStaticParams`),页面渲染时间超过默认的 60 秒超时,通常由于数据获取缓慢或计算量大。
English
During static generation (e.g., with `output: export` or `generateStaticParams`), a page takes longer than the default 60-second timeout to render, often due to slow data fetching or heavy computation.
官方文档
https://nextjs.org/docs/messages/static-generation-timeout解决方案
-
Increase the timeout in next.config.js: `module.exports = { staticGenerationTimeout: 120 }` -
Optimize data fetching in the page: use caching, limit the number of items in `generateStaticParams`, or use incremental static regeneration.
无效尝试
常见但无效的做法:
-
70% 失败
This prevents static generation entirely, but if the project requires static export (`output: export`), dynamic rendering is not allowed.
-
50% 失败
It only masks the issue; if the underlying cause (slow data fetch) isn't fixed, builds become unreasonably long.
-
85% 失败
Breaking change: without it, dynamic routes won't be pre-rendered for static export, causing build failures.