nextjs build_error ai_generated partial

错误:路径 '/[slug]' 的静态生成在 60 秒后超时。考虑增加静态生成超时时间或使用动态渲染。

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

其他格式: JSON · Markdown 中文 · English
87%修复率
84%置信度
1证据数
2024-07-01首次发现

版本兼容性

版本状态引入弃用备注
Next.js 14.2.5 active
Next.js 13.5.0 active

根因分析

在静态生成期间,generateStaticParams 函数或动态路由的页面渲染耗时超过默认的 60 秒超时,通常是由于数据获取缓慢或路径过多。

English

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

官方文档

https://nextjs.org/docs/messages/static-generation-timeout

解决方案

  1. Optimize generateStaticParams by caching API calls: const paths = await fetch('/api/paths', { next: { revalidate: 3600 } })
  2. Use incremental static regeneration (ISR) with revalidate instead of full static generation: export const revalidate = 3600
  3. Switch to dynamic rendering for this page by removing generateStaticParams or adding export const dynamic = 'force-dynamic'

无效尝试

常见但无效的做法:

  1. 50% 失败

    This only masks the problem; if the underlying data fetch is slow, it may still timeout at higher limits.

  2. 70% 失败

    This breaks the dynamic routing functionality and may not be feasible for content-driven sites.