nextjs build_error ai_generated partial

Error: Static generation timed out after 60 seconds for path '/[slug]'. Consider increasing the static generation timeout.

ID: nextjs/static-generation-timeout-slug

Also available as: JSON · Markdown · 中文
75%Fix Rate
83%Confidence
1Evidence
2023-08-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Next.js 13.3+ active
Next.js 14.0 active
Next.js 15.0 active

Root Cause

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.

generic

中文

在静态生成期间(例如,使用 `output: export` 或 `generateStaticParams`),页面渲染时间超过默认的 60 秒超时,通常由于数据获取缓慢或计算量大。

Official Documentation

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

Workarounds

  1. 80% success Increase the timeout in next.config.js: `module.exports = { staticGenerationTimeout: 120 }`
    Increase the timeout in next.config.js: `module.exports = { staticGenerationTimeout: 120 }`
  2. 90% success Optimize data fetching in the page: use caching, limit the number of items in `generateStaticParams`, or use incremental static regeneration.
    Optimize data fetching in the page: use caching, limit the number of items in `generateStaticParams`, or use incremental static regeneration.

中文步骤

  1. Increase the timeout in next.config.js: `module.exports = { staticGenerationTimeout: 120 }`
  2. Optimize data fetching in the page: use caching, limit the number of items in `generateStaticParams`, or use incremental static regeneration.

Dead Ends

Common approaches that don't work:

  1. 70% fail

    This prevents static generation entirely, but if the project requires static export (`output: export`), dynamic rendering is not allowed.

  2. 50% fail

    It only masks the issue; if the underlying cause (slow data fetch) isn't fixed, builds become unreasonably long.

  3. 85% fail

    Breaking change: without it, dynamic routes won't be pre-rendered for static export, causing build failures.