Prerender - maximum callstack size exceeded

I have a route where I am trying to prerender ~274k pages, but I am getting this error during yarn rw build:
`Starting prerendering…

RangeError: Maximum call stack size exceeded`

I can’t seem to find any open threads or github issues about this. Also this is the same error in the server environment and my local environment. Any ideas?

1 Like

Hey @atyler! :wave: … I’m going to “phone a friend.” Hopefully, we can get to the bottom of it!

Hey @atyler, I can reproduce this with a very basic reproduction. I’ll dig in some more and hopefully have something to share in either tomorrow or over the weekend.

I have a proposed fix:

I’ll update again here if this is accepted and released or if we decide we need to try a different approach to fixing this.

Hey @atyler :wave:

I’ve released that fix in v7.7.2. If you could try that out and see if it fixes your problem with the CLI crashing?

I suspect prerendering that many routes will likely take some time. The fix above didn’t try to make it any faster.

1 Like

Yep just verified this fixed it! thanks so much for such a speedy turnaround!

2 Likes

Just out of curiosity – how long did it take?

Not sure I only let it run for about an hour. looks like maybe the whole run would take around 8 if i had let it run. Yeh might need to figure something else out. Definitely don’t necessarily need to run this every build since the data on the pages only changes once every two weeks all at the same time.

Hi @atyler some years ago (maybe 8 or so … wow … early Netlify days) I built an app using Contentful and Middleman as a static app deployed to Netlify. It grew to render tens of thousands of pages on each build. It was taking 6+ hrs and maxed out Netlify’s build memory – even on an enterprise plan.

I did a number of optimizations because as you said, not all the content changed.

In fact you can read about if here as one of my early interactions with Redwood from 2020:

I got builds down from 6 hrs to 90 mins to 15 mins to 2 mins. But it was quite a bit of work and acrobatics.

I was caching queried data, caching generated pages, and only re-generating new or recently updated content with multiple steps. It was involved, but helped.

However – the real solution was the 2 min version; make it a React app with an api and a Netlify function to be the api endpoint – a crude Redwood :).

For me it was better (because I knew form data analytics that most traffic was for recent content) to have:

  • dynamic data fetch
  • generate and publish full sitemaps and such generated for SEO (bulk of build time, besides code)
  • use Netlify prerender for SEO unfurling

The upcoming Redwood SSR will make this much easier since don’t need to do the Netlfy pre-render service.

Thought I’d share as someone who did render 30k+ pages.

Do let us know how you get on.