Debugging slow static page generation
Unanswered
Norwegian Lundehund posted this in #help-forum
Norwegian LundehundOP
Hi there, we're noticing that in CI, our next.js builds are timing out and restarting during the "Generating static pages" stage - we're using the pages directory and babel (no swc yet) in our project:
I'm wondering if anyone has some ideas on how to debug this issue. I'm particularly interested in ways I can visualize the trace file that's generated with
Any help is appreciated! ðŸ™
warn - Restarted static page generation for /setup because it took more than 60 seconds
I'm wondering if anyone has some ideas on how to debug this issue. I'm particularly interested in ways I can visualize the trace file that's generated with
next build --profile
- can't seem to figure it out.Any help is appreciated! ðŸ™
17 Replies
you can also just add a bunch of console.log to the getStaticProps of your CI to see where it is stuck
Norwegian LundehundOP
not sure I follow how that would help? most of our static pages don't have
getStaticProps
fwiw.American black bear
The same problem occurred yesterday on vercel
how is
/setup
taking that long then? can you show me the code that is run when /setup
is statically generated?Norwegian LundehundOP
My current hunch is that there is like an optimizely provider that wraps the react tree and tries to do a network call during SSG and then it times out.
I cannot share a meaningful snippet because there's a ton of context providers and wrapper components in _app.tsx and you won't get the full picture without all that (sadly cannot share the whole thing).
_app.tsx doesn't have static data fetching methods so it doesn't take long to generate
the issue lies in the static data fetching methods (getStatic(Paths|Props)) in your pages
Norwegian LundehundOP
None of the static pages I have export
getStatic(Paths|Props)
functionsthen honestly i can't think of what could take static generation 60 seconds
does it happen now? when you retry building
does it happen when you build locally?
Norwegian LundehundOP
No worries 🙂
and yes on all counts.
and yes on all counts.
I'd just like to read the
.next/trace
that gets generated with --profile
flagso far I cannot open it with the zipkin ui or react-devtools
American black bear
I don't know if it will help you. All night yesterday there was an error similar to yours on vercel. Now, with a new build, it has disappeared.
Norwegian LundehundOP
That's useful to know. I'm not using Vercel for our project (would love to though).