sPavl0v / react-spa-prenderer

MIT License
34 stars 17 forks source link

Add closing of Page #25

Open aayusharyan opened 8 months ago

aayusharyan commented 8 months ago

Summary:

Adding closing of Page for each render because some OS does not do automatic garbage collection and keeps the Chrome tabs open in the background causing heavy memory consumption and eventual failure.

Situation:

I am using this to render a little bit over 450 pages using GitHub action. With the current code, it takes 2.5 hours and crashes after rendering around 250 pages. (That means, in Github Action runner, all these 250 tabs are opening in parallel and causing this crash).

ss 69

The error this runner throws is this.

ss 70

The reason for this lost connection is basically the runner went out of memory and wasn't even able to update the status to Github about this job.

Fix:

Close the tab after rendering of html is completed. After this change, the runner is able to complete the job in less than 10 minutes to render the whole set of 450 pages without breaking a sweat.

ss 71

The base build takes around 5-6 minutes, the spa-pre-render is a post build step. So, total job completes in 15 mintues, around 5-6 minutes to build, which means, this is able to complete the rendering in less than 10 minutes for 450+ pages.

Conclusion:

Adding the page.close will help in better memory management of chrome tabs and not depend on the host OS garbage collector.