geelen / react-snapshot

A zero-configuration static pre-renderer for React apps
MIT License
1.66k stars 105 forks source link

"RangeError: Maximum call stack size exceeded" after crawling #133

Open controversial opened 4 years ago

controversial commented 4 years ago

Filing this issue as #87 doesn't seem to have a resolution.

On our site, we use react-snapshot to save snapshots of 524 routes and generate a sitemap. In the react-snapshot output, we see the following:

Screen Shot 2020-07-21 at 10 36 00 PM

This error occurs after the entire site tree is crawled (all routes of our site are logged to the console with “Saving”).

Last month we encountered this same issue, and found that the solution was to make the following change to our nesting pattern:

Before
  • /a1/b1, /a1/b2, /a1/b3
  • /a2/b1, /a2/b2, /a2/b3
    ...
  • /a50/b1, /a50/b2, /a50/b3
After
  • /b1/a1, /b1/a2, ... /b1/a50
  • /b2/a1, /b2/a2, ... /b2/a50
  • /b3/a1, /b3/a2, ... /b3/a50

that is, we changed our route structure from “many routes, each containing a few routes” to “a few routes, each containing many routes.”

Although that approach worked before, now that we have more routes in our app, we can no longer avoid the error this way.