Nextjs export timeout configuration
Asked Answered
M

2

22

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.

Mccarthy answered 27/11, 2021 at 12:9 Comment(7)
Looks like it goes in next.config.json. Did it not work for you? What error did you face?Holliman
Facing the same issue. Changed the time to 500 seconds but still getting the error.Stackhouse
Hi, I tried again with putting the following code in next.config.js: module.exports = (phase, { defaultConfig }) => { @type {import('next').NextConfig} const nextConfig = { staticPageGenerationTimeout: 2000 /* config options here */ } return nextConfig } According to the documentation. But it doesn't work stillMccarthy
What version of Next.js are you using?Disrepair
I am using Next.js v12.0.4 . However I found out Next doesn't like that i am using html <img> tags instead of the <Image> inbuilt in NextJS. I don't know if this is the problem, I will be solving it soon and seeing if that was the issue all alongMccarthy
What data does it collect, can we turn it off ?Crust
Hi, Yes, it is solved now :)Mccarthy
V
31

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,
}
Velda answered 21/12, 2021 at 10:13 Comment(0)
F
0

maybe you are using <img/> html tag instead of next image component , i had same problem and solving with replace that

Frobisher answered 12/4, 2023 at 20:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.