Search code examples
buildstaticnext.jstimeoutexport

Nextjs export timeout configuration


I am building a website with NextJS that takes some time to build. It has to create a big dictionary, so when I run next dev it takes around 2 minutes to build.

The issue is, when I run next export to get a static version of the website there is a timeout problem, because the build takes (as I said before), 2 minutes, whihc exceeds the 60 seconds limit pre-configured in next.

In the NEXT documentation: https://nextjs.org/docs/messages/static-page-generation-timeout it explains that you can increase the timeout limit, whose default is 60 seconds: "Increase the timeout by changing the staticPageGenerationTimeout configuration option (default 60 in seconds)."

However it does not specify WHERE you can set that configuration option. In next.config.json? in package.json?

I could not find this information anywhere, and my blind tries of putting this parameter in some of the files mentioned before did not work out at all. So, Does anybody know how to set the timeout of next export? Thank you in advance.


Solution

  • They were a bit more clear in the basic-features/data-fetching part of the docs that it should be placed in the next.config.js

    I added this to mine and it worked (got rid of the Error: Collecting page data for /path/[pk] is still timing out after 2 attempts. See more info here https://nextjs.org/docs/messages/page-data-collection-timeout build error):

    // next.config.js
    module.exports = {
      // time in seconds of no pages generating during static
      // generation before timing out
      staticPageGenerationTimeout: 1000,
    }