# 错误：路径 '/[slug]' 的静态生成在 60 秒后超时。考虑在 next.config.js 中增加静态生成超时时间。

- **ID:** `nextjs/static-generation-timeout-path`
- **领域:** nextjs
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

使用 generateStaticParams 或静态生成（output: 'export' 或 dynamicParams: false）的页面生成所有静态页面耗时超过默认的 60 秒超时。这通常是由于数据获取缓慢或动态路由过多。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Next.js 14.0.0 | active | — | — |
| Next.js 15.0.0 | active | — | — |

## 解决方案

1. ```
   在 next.config.js 中使用 experimental.staticGenerationTimeout 选项增加静态生成超时时间。
   ```
2. ```
   优化 generateStaticParams 以更高效地获取数据。使用批量获取、缓存或限制返回的路径数量。
   ```
3. ```
   如果使用 output: 'export'，考虑对具有许多动态路由的页面切换到部分预渲染或 ISR。或者，使用自定义构建脚本分批生成页面。
   ```

## 无效尝试

- **Setting dynamicParams: true in the page segment config to allow dynamic rendering for missed routes.** — This only affects runtime behavior for ungenerated routes, not the static generation timeout itself; the timeout still applies to the initial build. (60% 失败率)
- **Removing generateStaticParams entirely to let Next.js handle all routes dynamically.** — This changes the page to dynamic rendering, which may not be desired for SEO or performance; also, if output: 'export' is set, this will cause a build error. (70% 失败率)
- **Adding revalidate to the page's fetch calls to enable ISR, thinking it bypasses static generation timeout.** — ISR still requires initial static generation; the timeout applies to the first build, not runtime revalidation. (50% 失败率)
